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

Diff for /src/usr.bin/rsh/Attic/rsh.c between version 1.30 and 1.31

version 1.30, 2002/08/12 02:31:43 version 1.31, 2003/04/08 22:11:56
Line 58 
Line 58 
 #include <stdlib.h>  #include <stdlib.h>
 #include <unistd.h>  #include <unistd.h>
 #include <errno.h>  #include <errno.h>
   #include <err.h>
 #include <string.h>  #include <string.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include "pathnames.h"  #include "pathnames.h"
Line 465 
Line 466 
 copyargs(char **argv)  copyargs(char **argv)
 {  {
         char **ap, *p, *args;          char **ap, *p, *args;
         int cc;          size_t cc, len;
   
         cc = 0;          cc = 0;
         for (ap = argv; *ap; ++ap)          for (ap = argv; *ap; ++ap)
                 cc += strlen(*ap) + 1;                  cc += strlen(*ap) + 1;
         if (!(args = malloc((u_int)cc))) {          if ((args = malloc(cc)) == NULL)
                 (void)fprintf(stderr, "rsh: %s.\n", strerror(ENOMEM));                  err(1, NULL);
                 exit(1);  
         }  
         for (p = args, ap = argv; *ap; ++ap) {          for (p = args, ap = argv; *ap; ++ap) {
                 (void)strcpy(p, *ap);                  len = strlcpy(p, *ap, cc);
                 for (p = strcpy(p, *ap); *p; ++p);                  if (len >= cc)
                 if (ap[1])                          errx(1, "copyargs overflow");
                   p += len;
                   cc -= len;
                   if (ap[1]) {
                         *p++ = ' ';                          *p++ = ' ';
                           cc--;
                   }
         }          }
         return(args);          return(args);
 }  }

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31