[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.144 and 1.145

version 1.144, 2015/11/23 01:23:56 version 1.145, 2015/12/07 02:38:54
Line 58 
Line 58 
 #include "atomicio.h"  #include "atomicio.h"
   
 #define PORT_MAX        65535  #define PORT_MAX        65535
 #define PORT_MAX_LEN    6  
 #define UNIX_DG_TMP_SOCKET_SIZE 19  #define UNIX_DG_TMP_SOCKET_SIZE 19
   
 #define POLL_STDIN 0  #define POLL_STDIN 0
Line 1289 
Line 1288 
                         lo = cp;                          lo = cp;
                 }                  }
   
                 /* Load ports sequentially. */                  /*
                 for (cp = lo; cp <= hi; cp++) {                   * Initialize portlist with a random permutation.  Based on
                         portlist[x] = calloc(1, PORT_MAX_LEN);                   * Knuth, as in ip_randomid() in sys/netinet/ip_id.c.
                         if (portlist[x] == NULL)                   */
                                 err(1, NULL);  
                         snprintf(portlist[x], PORT_MAX_LEN, "%d", cp);  
                         x++;  
                 }  
   
                 /* Randomly swap ports. */  
                 if (rflag) {                  if (rflag) {
                         int y;                          for (x = 0; x <= hi - lo; x++) {
                         char *c;                                  cp = arc4random_uniform(x + 1);
                                   portlist[x] = portlist[cp];
                         for (x = 0; x <= (hi - lo); x++) {                                  if (asprintf(&portlist[cp], "%d", x + lo) < 0)
                                 y = (arc4random() & 0xFFFF) % (hi - lo);                                          err(1, "asprintf");
                                 c = portlist[x];                          }
                                 portlist[x] = portlist[y];                  } else { /* Load ports sequentially. */
                                 portlist[y] = c;                          for (cp = lo; cp <= hi; cp++) {
                                   if (asprintf(&portlist[x], "%d", cp) < 0)
                                           err(1, "asprintf");
                                   x++;
                         }                          }
                 }                  }
         } else {          } else {

Legend:
Removed from v.1.144  
changed lines
  Added in v.1.145