[BACK]Return to sftp-int.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/Attic/sftp-int.c between version 1.60 and 1.61

version 1.60, 2003/05/15 03:43:59 version 1.61, 2003/07/19 00:45:53
Line 334 
Line 334 
 {  {
         const char *cp = *cpp, *end;          const char *cp = *cpp, *end;
         char quot;          char quot;
         int i;          int i, j;
   
         cp += strspn(cp, WHITESPACE);          cp += strspn(cp, WHITESPACE);
         if (!*cp) {          if (!*cp) {
Line 343 
Line 343 
                 return (0);                  return (0);
         }          }
   
           *path = xmalloc(strlen(cp) + 1);
   
         /* Check for quoted filenames */          /* Check for quoted filenames */
         if (*cp == '\"' || *cp == '\'') {          if (*cp == '\"' || *cp == '\'') {
                 quot = *cp++;                  quot = *cp++;
   
                 end = strchr(cp, quot);                  /* Search for terminating quote, unescape some chars */
                 if (end == NULL) {                  for (i = j = 0; i <= strlen(cp); i++) {
                         error("Unterminated quote");                          if (cp[i] == quot) {    /* Found quote */
                         goto fail;                                  (*path)[j] = '\0';
                                   break;
                           }
                           if (cp[i] == '\0') {    /* End of string */
                                   error("Unterminated quote");
                                   goto fail;
                           }
                           if (cp[i] == '\\') {    /* Escaped characters */
                                   i++;
                                   if (cp[i] != '\'' && cp[i] != '\"' &&
                                       cp[i] != '\\') {
                                           error("Bad escaped character '\%c'",
                                               cp[i]);
                                           goto fail;
                                   }
                           }
                           (*path)[j++] = cp[i];
                 }                  }
                 if (cp == end) {  
                   if (j == 0) {
                         error("Empty quotes");                          error("Empty quotes");
                         goto fail;                          goto fail;
                 }                  }
                 *cpp = end + 1 + strspn(end + 1, WHITESPACE);                  *cpp = cp + i + strspn(cp + i, WHITESPACE);
         } else {          } else {
                 /* Read to end of filename */                  /* Read to end of filename */
                 end = strpbrk(cp, WHITESPACE);                  end = strpbrk(cp, WHITESPACE);
                 if (end == NULL)                  if (end == NULL)
                         end = strchr(cp, '\0');                          end = strchr(cp, '\0');
                 *cpp = end + strspn(end, WHITESPACE);                  *cpp = end + strspn(end, WHITESPACE);
   
                   memcpy(*path, cp, end - cp);
                   (*path)[end - cp] = '\0';
         }          }
           return (0);
   
         i = end - cp;  
   
         *path = xmalloc(i + 1);  
         memcpy(*path, cp, i);  
         (*path)[i] = '\0';  
         return(0);  
   
  fail:   fail:
         *path = NULL;          xfree(*path);
           *path = NULL;
         return (-1);          return (-1);
 }  }
   

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.61