[BACK]Return to channels.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/channels.c between version 1.392 and 1.393

version 1.392, 2019/06/07 14:18:48 version 1.393, 2019/06/28 13:35:04
Line 1661 
Line 1661 
                 chan_mark_dead(ssh, c);                  chan_mark_dead(ssh, c);
                 errno = oerrno;                  errno = oerrno;
         }          }
         if (newsock < 0) {          if (newsock == -1) {
                 if (errno != EINTR && errno != EWOULDBLOCK &&                  if (errno != EINTR && errno != EWOULDBLOCK &&
                     errno != ECONNABORTED)                      errno != ECONNABORTED)
                         error("accept: %.100s", strerror(errno));                          error("accept: %.100s", strerror(errno));
Line 1804 
Line 1804 
   
         addrlen = sizeof(addr);          addrlen = sizeof(addr);
         newsock = accept(c->sock, (struct sockaddr *)&addr, &addrlen);          newsock = accept(c->sock, (struct sockaddr *)&addr, &addrlen);
         if (newsock < 0) {          if (newsock == -1) {
                 if (errno != EINTR && errno != EWOULDBLOCK &&                  if (errno != EINTR && errno != EWOULDBLOCK &&
                     errno != ECONNABORTED)                      errno != ECONNABORTED)
                         error("accept: %.100s", strerror(errno));                          error("accept: %.100s", strerror(errno));
Line 1843 
Line 1843 
   
         addrlen = sizeof(addr);          addrlen = sizeof(addr);
         newsock = accept(c->sock, (struct sockaddr *)&addr, &addrlen);          newsock = accept(c->sock, (struct sockaddr *)&addr, &addrlen);
         if (newsock < 0) {          if (newsock == -1) {
                 error("accept from auth socket: %.100s", strerror(errno));                  error("accept from auth socket: %.100s", strerror(errno));
                 if (errno == EMFILE || errno == ENFILE)                  if (errno == EMFILE || errno == ENFILE)
                         c->notbefore = monotime() + 1;                          c->notbefore = monotime() + 1;
Line 1871 
Line 1871 
                 fatal(":%s: channel %d: no remote id", __func__, c->self);                  fatal(":%s: channel %d: no remote id", __func__, c->self);
         /* for rdynamic the OPEN_CONFIRMATION has been sent already */          /* for rdynamic the OPEN_CONFIRMATION has been sent already */
         isopen = (c->type == SSH_CHANNEL_RDYNAMIC_FINISH);          isopen = (c->type == SSH_CHANNEL_RDYNAMIC_FINISH);
         if (getsockopt(c->sock, SOL_SOCKET, SO_ERROR, &err, &sz) < 0) {          if (getsockopt(c->sock, SOL_SOCKET, SO_ERROR, &err, &sz) == -1) {
                 err = errno;                  err = errno;
                 error("getsockopt SO_ERROR failed");                  error("getsockopt SO_ERROR failed");
         }          }
Line 1943 
Line 1943 
                 return 1;                  return 1;
   
         len = read(c->rfd, buf, sizeof(buf));          len = read(c->rfd, buf, sizeof(buf));
         if (len < 0 && (errno == EINTR || errno == EAGAIN))          if (len == -1 && (errno == EINTR || errno == EAGAIN))
                 return 1;                  return 1;
         if (len <= 0) {          if (len <= 0) {
                 debug2("channel %d: read<=0 rfd %d len %zd",                  debug2("channel %d: read<=0 rfd %d len %zd",
Line 2011 
Line 2011 
                 /* ignore truncated writes, datagrams might get lost */                  /* ignore truncated writes, datagrams might get lost */
                 len = write(c->wfd, buf, dlen);                  len = write(c->wfd, buf, dlen);
                 free(data);                  free(data);
                 if (len < 0 && (errno == EINTR || errno == EAGAIN))                  if (len == -1 && (errno == EINTR || errno == EAGAIN))
                         return 1;                          return 1;
                 if (len <= 0)                  if (len <= 0)
                         goto write_fail;                          goto write_fail;
Line 2019 
Line 2019 
         }          }
   
         len = write(c->wfd, buf, dlen);          len = write(c->wfd, buf, dlen);
         if (len < 0 && (errno == EINTR || errno == EAGAIN))          if (len == -1 && (errno == EINTR || errno == EAGAIN))
                 return 1;                  return 1;
         if (len <= 0) {          if (len <= 0) {
  write_fail:   write_fail:
Line 2070 
Line 2070 
         len = write(c->efd, sshbuf_ptr(c->extended),          len = write(c->efd, sshbuf_ptr(c->extended),
             sshbuf_len(c->extended));              sshbuf_len(c->extended));
         debug2("channel %d: written %zd to efd %d", c->self, len, c->efd);          debug2("channel %d: written %zd to efd %d", c->self, len, c->efd);
         if (len < 0 && (errno == EINTR || errno == EAGAIN))          if (len == -1 && (errno == EINTR || errno == EAGAIN))
                 return 1;                  return 1;
         if (len <= 0) {          if (len <= 0) {
                 debug2("channel %d: closing write-efd %d", c->self, c->efd);                  debug2("channel %d: closing write-efd %d", c->self, c->efd);
Line 2098 
Line 2098 
   
         len = read(c->efd, buf, sizeof(buf));          len = read(c->efd, buf, sizeof(buf));
         debug2("channel %d: read %zd from efd %d", c->self, len, c->efd);          debug2("channel %d: read %zd from efd %d", c->self, len, c->efd);
         if (len < 0 && (errno == EINTR || errno == EAGAIN))          if (len == -1 && (errno == EINTR || errno == EAGAIN))
                 return 1;                  return 1;
         if (len <= 0) {          if (len <= 0) {
                 debug2("channel %d: closing read-efd %d",                  debug2("channel %d: closing read-efd %d",
Line 2186 
Line 2186 
         if (sshbuf_len(c->input) < need) {          if (sshbuf_len(c->input) < need) {
                 rlen = need - sshbuf_len(c->input);                  rlen = need - sshbuf_len(c->input);
                 len = read(c->rfd, buf, MINIMUM(rlen, CHAN_RBUF));                  len = read(c->rfd, buf, MINIMUM(rlen, CHAN_RBUF));
                 if (len < 0 && (errno == EINTR || errno == EAGAIN))                  if (len == -1 && (errno == EINTR || errno == EAGAIN))
                         return sshbuf_len(c->input);                          return sshbuf_len(c->input);
                 if (len <= 0) {                  if (len <= 0) {
                         debug2("channel %d: ctl read<=0 rfd %d len %zd",                          debug2("channel %d: ctl read<=0 rfd %d len %zd",
Line 2250 
Line 2250 
                 return;                  return;
   
         len = write(c->wfd, sshbuf_ptr(c->output), sshbuf_len(c->output));          len = write(c->wfd, sshbuf_ptr(c->output), sshbuf_len(c->output));
         if (len < 0 && (errno == EINTR || errno == EAGAIN))          if (len == -1 && (errno == EINTR || errno == EAGAIN))
                 return;                  return;
         if (len <= 0) {          if (len <= 0) {
                 chan_mark_dead(ssh, c);                  chan_mark_dead(ssh, c);
Line 2298 
Line 2298 
                 return;                  return;
         }          }
   
         if (getpeereid(newsock, &euid, &egid) < 0) {          if (getpeereid(newsock, &euid, &egid) == -1) {
                 error("%s getpeereid failed: %s", __func__,                  error("%s getpeereid failed: %s", __func__,
                     strerror(errno));                      strerror(errno));
                 close(newsock);                  close(newsock);
Line 3428 
Line 3428 
                 }                  }
                 /* Create a port to listen for the host. */                  /* Create a port to listen for the host. */
                 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);                  sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                 if (sock < 0) {                  if (sock == -1) {
                         /* this is no error since kernel may not support ipv6 */                          /* this is no error since kernel may not support ipv6 */
                         verbose("socket [%s]:%s: %.100s", ntop, strport,                          verbose("socket [%s]:%s: %.100s", ntop, strport,
                             strerror(errno));                              strerror(errno));
Line 3441 
Line 3441 
                     ntop, strport);                      ntop, strport);
   
                 /* Bind the socket to the address. */                  /* Bind the socket to the address. */
                 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {                  if (bind(sock, ai->ai_addr, ai->ai_addrlen) == -1) {
                         /*                          /*
                          * address can be in if use ipv6 address is                           * address can be in if use ipv6 address is
                          * already bound                           * already bound
Line 3452 
Line 3452 
                         continue;                          continue;
                 }                  }
                 /* Start listening for connections on the socket. */                  /* Start listening for connections on the socket. */
                 if (listen(sock, SSH_LISTEN_BACKLOG) < 0) {                  if (listen(sock, SSH_LISTEN_BACKLOG) == -1) {
                         error("listen [%s]:%s: %.100s", ntop, strport,                          error("listen [%s]:%s: %.100s", ntop, strport,
                             strerror(errno));                              strerror(errno));
                         close(sock);                          close(sock);
Line 4471 
Line 4471 
                 if (sc->channels[i] == NULL || !sc->channels[i]->client_tty ||                  if (sc->channels[i] == NULL || !sc->channels[i]->client_tty ||
                     sc->channels[i]->type != SSH_CHANNEL_OPEN)                      sc->channels[i]->type != SSH_CHANNEL_OPEN)
                         continue;                          continue;
                 if (ioctl(sc->channels[i]->rfd, TIOCGWINSZ, &ws) < 0)                  if (ioctl(sc->channels[i]->rfd, TIOCGWINSZ, &ws) == -1)
                         continue;                          continue;
                 channel_request_start(ssh, i, "window-change", 0);                  channel_request_start(ssh, i, "window-change", 0);
                 if ((r = sshpkt_put_u32(ssh, (u_int)ws.ws_col)) != 0 ||                  if ((r = sshpkt_put_u32(ssh, (u_int)ws.ws_col)) != 0 ||
Line 4574 
Line 4574 
                                 continue;                                  continue;
                         sock = socket(ai->ai_family, ai->ai_socktype,                          sock = socket(ai->ai_family, ai->ai_socktype,
                             ai->ai_protocol);                              ai->ai_protocol);
                         if (sock < 0) {                          if (sock == -1) {
                                 error("socket: %.100s", strerror(errno));                                  error("socket: %.100s", strerror(errno));
                                 freeaddrinfo(aitop);                                  freeaddrinfo(aitop);
                                 return -1;                                  return -1;
                         }                          }
                         set_reuseaddr(sock);                          set_reuseaddr(sock);
                         if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {                          if (bind(sock, ai->ai_addr, ai->ai_addrlen) == -1) {
                                 debug2("%s: bind port %d: %.100s", __func__,                                  debug2("%s: bind port %d: %.100s", __func__,
                                     port, strerror(errno));                                      port, strerror(errno));
                                 close(sock);                                  close(sock);
Line 4604 
Line 4604 
         /* Start listening for connections on the socket. */          /* Start listening for connections on the socket. */
         for (n = 0; n < num_socks; n++) {          for (n = 0; n < num_socks; n++) {
                 sock = socks[n];                  sock = socks[n];
                 if (listen(sock, SSH_LISTEN_BACKLOG) < 0) {                  if (listen(sock, SSH_LISTEN_BACKLOG) == -1) {
                         error("listen: %.100s", strerror(errno));                          error("listen: %.100s", strerror(errno));
                         close(sock);                          close(sock);
                         return -1;                          return -1;
Line 4636 
Line 4636 
         struct sockaddr_un addr;          struct sockaddr_un addr;
   
         sock = socket(AF_UNIX, SOCK_STREAM, 0);          sock = socket(AF_UNIX, SOCK_STREAM, 0);
         if (sock < 0)          if (sock == -1)
                 error("socket: %.100s", strerror(errno));                  error("socket: %.100s", strerror(errno));
         memset(&addr, 0, sizeof(addr));          memset(&addr, 0, sizeof(addr));
         addr.sun_family = AF_UNIX;          addr.sun_family = AF_UNIX;
Line 4724 
Line 4724 
         for (ai = aitop; ai; ai = ai->ai_next) {          for (ai = aitop; ai; ai = ai->ai_next) {
                 /* Create a socket. */                  /* Create a socket. */
                 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);                  sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                 if (sock < 0) {                  if (sock == -1) {
                         debug2("socket: %.100s", strerror(errno));                          debug2("socket: %.100s", strerror(errno));
                         continue;                          continue;
                 }                  }
                 /* Connect it to the display. */                  /* Connect it to the display. */
                 if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0) {                  if (connect(sock, ai->ai_addr, ai->ai_addrlen) == -1) {
                         debug2("connect %.100s port %u: %.100s", buf,                          debug2("connect %.100s port %u: %.100s", buf,
                             6000 + display_number, strerror(errno));                              6000 + display_number, strerror(errno));
                         close(sock);                          close(sock);

Legend:
Removed from v.1.392  
changed lines
  Added in v.1.393