source: npl/system/netkit-ftp/patches/33-netkit-ftp-0.17-token.patch @ f9ce31e

perl-5.22
Last change on this file since f9ce31e was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 1.5 KB
  • ftp/ruserpass.c

    diff -rup netkit-ftp-0.17/ftp/ruserpass.c netkit-ftp-0.17-new/ftp/ruserpass.c
    old new static int token(void); 
    5858#define ID      10
    5959#define MACH    11
    6060
    61 static char tokval[100];
     61#define MAXTOKENLEN 4096
     62static char tokval[MAXTOKENLEN];
    6263
    6364static struct toktab {
    6465        const char *tokstr;
    bad: 
    249250        return(-1);
    250251}
    251252
    252 static 
     253static
    253254int
    254255token(void)
    255256{
    256257        char *cp;
    257258        int c;
    258259        struct toktab *t;
     260        size_t toklen = 0;
     261        int showwarn = 1;
     262        int quote = 0;
    259263
    260264        if (feof(cfile))
    261265                return (0);
    token(void) 
    266270                return (0);
    267271        cp = tokval;
    268272        if (c == '"') {
    269                 while ((c = getc(cfile)) != EOF && c != '"') {
    270                         if (c == '\\')
    271                                 c = getc(cfile);
    272                         *cp++ = c;
    273                 }
    274         } else {
     273                quote = 1;
     274        }
     275        else {
    275276                *cp++ = c;
    276                 while ((c = getc(cfile)) != EOF
    277                     && c != '\n' && c != '\t' && c != ' ' && c != ',') {
    278                         if (c == '\\')
    279                                 c = getc(cfile);
    280                         *cp++ = c;
     277                toklen++;
     278        }
     279        while ((c = getc(cfile)) != EOF) {
     280                if (c == '"')
     281                        break;
     282                if (c == '\\')
     283                        c = getc(cfile);
     284                if (!quote && (c == '\n' || c == '\t' || c == ' ' || c == ','))
     285                        break;
     286                if (toklen >= MAXTOKENLEN) {
     287                        if (showwarn) {
     288                                fprintf(stderr,
     289                                                "Warning: .netrc token too long, will be trunctated to %zd characters\n",
     290                                                toklen);
     291                                showwarn = 0;
     292                        }
     293                        continue;
    281294                }
     295                *cp++ = c;
     296                toklen++;
    282297        }
     298
    283299        *cp = 0;
    284300        if (tokval[0] == 0)
    285301                return (0);
Note: See TracBrowser for help on using the repository browser.