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

Diff for /src/usr.bin/nc/netcat.c between version 1.154 and 1.155

version 1.154, 2016/06/27 23:58:08 version 1.155, 2016/06/28 00:01:10
Line 668 
Line 668 
 unix_bind(char *path, int flags)  unix_bind(char *path, int flags)
 {  {
         struct sockaddr_un s_un;          struct sockaddr_un s_un;
         int s;          int s, save_errno;
   
         /* Create unix domain socket. */          /* Create unix domain socket. */
         if ((s = socket(AF_UNIX, flags | (uflag ? SOCK_DGRAM : SOCK_STREAM),          if ((s = socket(AF_UNIX, flags | (uflag ? SOCK_DGRAM : SOCK_STREAM),
Line 686 
Line 686 
         }          }
   
         if (bind(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) {          if (bind(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) {
                   save_errno = errno;
                 close(s);                  close(s);
                   errno = save_errno;
                 return (-1);                  return (-1);
         }          }
         return (s);          return (s);
Line 762 
Line 764 
 unix_connect(char *path)  unix_connect(char *path)
 {  {
         struct sockaddr_un s_un;          struct sockaddr_un s_un;
         int s;          int s, save_errno;
   
         if (uflag) {          if (uflag) {
                 if ((s = unix_bind(unix_dg_tmp_socket, SOCK_CLOEXEC)) < 0)                  if ((s = unix_bind(unix_dg_tmp_socket, SOCK_CLOEXEC)) < 0)
Line 782 
Line 784 
                 return (-1);                  return (-1);
         }          }
         if (connect(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) {          if (connect(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) {
                   save_errno = errno;
                 close(s);                  close(s);
                   errno = save_errno;
                 return (-1);                  return (-1);
         }          }
         return (s);          return (s);
Line 816 
Line 820 
 remote_connect(const char *host, const char *port, struct addrinfo hints)  remote_connect(const char *host, const char *port, struct addrinfo hints)
 {  {
         struct addrinfo *res, *res0;          struct addrinfo *res, *res0;
         int s, error, on = 1;          int s, error, on = 1, save_errno;
   
         if ((error = getaddrinfo(host, port, &hints, &res)))          if ((error = getaddrinfo(host, port, &hints, &res)))
                 errx(1, "getaddrinfo: %s", gai_strerror(error));                  errx(1, "getaddrinfo: %s", gai_strerror(error));
Line 855 
Line 859 
                         warn("connect to %s port %s (%s) failed", host, port,                          warn("connect to %s port %s (%s) failed", host, port,
                             uflag ? "udp" : "tcp");                              uflag ? "udp" : "tcp");
   
                   save_errno = errno;
                 close(s);                  close(s);
                   errno = save_errno;
                 s = -1;                  s = -1;
         } while ((res0 = res0->ai_next) != NULL);          } while ((res0 = res0->ai_next) != NULL);
   
Line 901 
Line 907 
 local_listen(char *host, char *port, struct addrinfo hints)  local_listen(char *host, char *port, struct addrinfo hints)
 {  {
         struct addrinfo *res, *res0;          struct addrinfo *res, *res0;
         int s, ret, x = 1;          int s, ret, x = 1, save_errno;
         int error;          int error;
   
         /* Allow nodename to be null. */          /* Allow nodename to be null. */
Line 933 
Line 939 
                     res0->ai_addrlen) == 0)                      res0->ai_addrlen) == 0)
                         break;                          break;
   
                   save_errno = errno;
                 close(s);                  close(s);
                   errno = save_errno;
                 s = -1;                  s = -1;
         } while ((res0 = res0->ai_next) != NULL);          } while ((res0 = res0->ai_next) != NULL);
   

Legend:
Removed from v.1.154  
changed lines
  Added in v.1.155