[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.152 and 1.153

version 1.152, 2016/05/28 20:14:58 version 1.153, 2016/06/02 04:26:32
Line 1283 
Line 1283 
         }          }
 }  }
   
   
   int
   strtoport(char *portstr, int udp)
   {
           struct servent *entry;
           const char *errstr;
           char *proto;
           int port = -1;
   
           proto = udp ? "udp" : "tcp";
   
           port = strtonum(portstr, 1, PORT_MAX, &errstr);
           if (errstr == NULL)
                   return port;
           if (errno != EINVAL)
                   errx(1, "port number %s: %s", errstr, portstr);
           if ((entry = getservbyname(portstr, proto)) == NULL)
                   errx(1, "service \"%s\" unknown", portstr);
           return ntohs(entry->s_port);
   }
   
 /*  /*
  * build_ports()   * build_ports()
  * Build an array of ports in portlist[], listing each port   * Build an array of ports in portlist[], listing each port
Line 1291 
Line 1312 
 void  void
 build_ports(char *p)  build_ports(char *p)
 {  {
         const char *errstr;  
         char *n;          char *n;
         int hi, lo, cp;          int hi, lo, cp;
         int x = 0;          int x = 0;
Line 1301 
Line 1321 
                 n++;                  n++;
   
                 /* Make sure the ports are in order: lowest->highest. */                  /* Make sure the ports are in order: lowest->highest. */
                 hi = strtonum(n, 1, PORT_MAX, &errstr);                  hi = strtoport(n, uflag);
                 if (errstr)                  lo = strtoport(p, uflag);
                         errx(1, "port number %s: %s", errstr, n);  
                 lo = strtonum(p, 1, PORT_MAX, &errstr);  
                 if (errstr)  
                         errx(1, "port number %s: %s", errstr, p);  
   
                 if (lo > hi) {                  if (lo > hi) {
                         cp = hi;                          cp = hi;
                         hi = lo;                          hi = lo;
Line 1333 
Line 1348 
                         }                          }
                 }                  }
         } else {          } else {
                 hi = strtonum(p, 1, PORT_MAX, &errstr);                  char *tmp;
                 if (errstr)  
                         errx(1, "port number %s: %s", errstr, p);                  hi = strtoport(p, uflag);
                 portlist[0] = strdup(p);                  if (asprintf(&tmp, "%d", hi) != -1)
                 if (portlist[0] == NULL)                          portlist[0] = tmp;
                   else
                         err(1, NULL);                          err(1, NULL);
         }          }
 }  }

Legend:
Removed from v.1.152  
changed lines
  Added in v.1.153