[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.2 and 1.3

version 1.2, 1997/01/15 23:43:43 version 1.3, 1997/04/07 19:55:26
Line 86 
Line 86 
 #ifndef INADDR_NONE  #ifndef INADDR_NONE
 #define INADDR_NONE 0xffffffff  #define INADDR_NONE 0xffffffff
 #endif  #endif
 #ifdef MAXHOSTNAMELEN  
 #undef MAXHOSTNAMELEN           /* might be too small on aix, so fix it */  
 #endif  
 #define MAXHOSTNAMELEN 256  
   
 struct host_poop {  struct host_poop {
   char name[MAXHOSTNAMELEN];    /* dns name */    char name[MAXHOSTNAMELEN];    /* dns name */
Line 370 
Line 366 
     if (! hostent)      if (! hostent)
 /* failure to look up a name is fatal, since we can't do anything with it */  /* failure to look up a name is fatal, since we can't do anything with it */
       bail ("%s: forward host lookup failed: ", name);        bail ("%s: forward host lookup failed: ", name);
     strncpy (poop->name, hostent->h_name, MAXHOSTNAMELEN - 2);      strncpy (poop->name, hostent->h_name, MAXHOSTNAMELEN - 1);
       poop->name[MAXHOSTNAMELEN - 1] = '\0';
     for (x = 0; hostent->h_addr_list[x] && (x < 8); x++) {      for (x = 0; hostent->h_addr_list[x] && (x < 8); x++) {
       memcpy (&poop->iaddrs[x], hostent->h_addr_list[x], sizeof (IA));        memcpy (&poop->iaddrs[x], hostent->h_addr_list[x], sizeof (IA));
       strncpy (poop->addrs[x], inet_ntoa (poop->iaddrs[x]),        strncpy (poop->addrs[x], inet_ntoa (poop->iaddrs[x]),
         sizeof (poop->addrs[0]));          sizeof (poop->addrs[0])-1);
         poop->addrs[x][sizeof (poop->addrs[0]) - 1] = '\0';
     } /* for x -> addrs, part A */      } /* for x -> addrs, part A */
     if (! o_verbose)                    /* if we didn't want to see the */      if (! o_verbose)                    /* if we didn't want to see the */
       return (poop);                    /* inverse stuff, we're done. */        return (poop);                    /* inverse stuff, we're done. */
Line 392 
Line 390 
   
   } else {  /* not INADDR_NONE: numeric addresses... */    } else {  /* not INADDR_NONE: numeric addresses... */
     memcpy (poop->iaddrs, &iaddr, sizeof (IA));      memcpy (poop->iaddrs, &iaddr, sizeof (IA));
     strncpy (poop->addrs[0], inet_ntoa (iaddr), sizeof (poop->addrs));      strncpy (poop->addrs[0], inet_ntoa (iaddr), sizeof (poop->addrs)-1);
       poop->addrs[0][sizeof (poop->addrs)-1] = '\0';
     if (numeric)                        /* if numeric-only, we're done */      if (numeric)                        /* if numeric-only, we're done */
       return (poop);        return (poop);
     if (! o_verbose)                    /* likewise if we don't want */      if (! o_verbose)                    /* likewise if we don't want */
Line 402 
Line 401 
     if (! hostent)      if (! hostent)
         holler ("%s: inverse host lookup failed: ", name);          holler ("%s: inverse host lookup failed: ", name);
     else {      else {
         strncpy (poop->name, hostent->h_name, MAXHOSTNAMELEN - 2);          strncpy (poop->name, hostent->h_name, MAXHOSTNAMELEN - 1);
           poop->name[MAXHOSTNAMELEN-1] = '\0';
         hostent = gethostbyname (poop->name);          hostent = gethostbyname (poop->name);
         if ((! hostent) || (! hostent->h_addr_list[0]))          if ((! hostent) || (! hostent->h_addr_list[0]))
           holler ("Warning: forward host lookup failed for %s: ",            holler ("Warning: forward host lookup failed for %s: ",
Line 452 
Line 452 
       y = ntohs (servent->s_port);        y = ntohs (servent->s_port);
       if (x != y)                       /* "never happen" */        if (x != y)                       /* "never happen" */
         holler ("Warning: port-bynum mismatch, %d != %d", x, y);          holler ("Warning: port-bynum mismatch, %d != %d", x, y);
       strncpy (portpoop->name, servent->s_name, sizeof (portpoop->name));        strncpy (portpoop->name, servent->s_name, sizeof (portpoop->name)-1);
         portpoop->name[sizeof (portpoop->name)-1] = '\0';
     } /* if servent */      } /* if servent */
     goto gp_finish;      goto gp_finish;
   } /* if pnum */    } /* if pnum */
Line 471 
Line 472 
       return (0);        return (0);
     servent = getservbyname (pstring, whichp);      servent = getservbyname (pstring, whichp);
     if (servent) {      if (servent) {
       strncpy (portpoop->name, servent->s_name, sizeof (portpoop->name));        strncpy (portpoop->name, servent->s_name, sizeof (portpoop->name)-1);
         portpoop->name[sizeof (portpoop->name)-1] = '\0';
       x = ntohs (servent->s_port);        x = ntohs (servent->s_port);
       goto gp_finish;        goto gp_finish;
     } /* if servent */      } /* if servent */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3