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

Last change on this file since 2154c77 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
RevLine 
[c5c522c]1diff -rup netkit-ftp-0.17/ftp/ruserpass.c netkit-ftp-0.17-new/ftp/ruserpass.c
2--- netkit-ftp-0.17/ftp/ruserpass.c     2012-10-29 15:11:10.593841089 +0100
3+++ netkit-ftp-0.17-new/ftp/ruserpass.c 2012-10-29 15:13:14.379822697 +0100
4@@ -58,7 +58,8 @@ static int token(void);
5 #define        ID      10
6 #define        MACH    11
7 
8-static char tokval[100];
9+#define MAXTOKENLEN 4096
10+static char tokval[MAXTOKENLEN];
11 
12 static struct toktab {
13        const char *tokstr;
14@@ -249,13 +250,16 @@ bad:
15        return(-1);
16 }
17 
18-static
19+static
20 int
21 token(void)
22 {
23        char *cp;
24        int c;
25        struct toktab *t;
26+       size_t toklen = 0;
27+       int showwarn = 1;
28+       int quote = 0;
29 
30        if (feof(cfile))
31                return (0);
32@@ -266,20 +270,32 @@ token(void)
33                return (0);
34        cp = tokval;
35        if (c == '"') {
36-               while ((c = getc(cfile)) != EOF && c != '"') {
37-                       if (c == '\\')
38-                               c = getc(cfile);
39-                       *cp++ = c;
40-               }
41-       } else {
42+               quote = 1;
43+       }
44+       else {
45                *cp++ = c;
46-               while ((c = getc(cfile)) != EOF
47-                   && c != '\n' && c != '\t' && c != ' ' && c != ',') {
48-                       if (c == '\\')
49-                               c = getc(cfile);
50-                       *cp++ = c;
51+               toklen++;
52+       }
53+       while ((c = getc(cfile)) != EOF) {
54+               if (c == '"')
55+                       break;
56+               if (c == '\\')
57+                       c = getc(cfile);
58+               if (!quote && (c == '\n' || c == '\t' || c == ' ' || c == ','))
59+                       break;
60+               if (toklen >= MAXTOKENLEN) {
61+                       if (showwarn) {
62+                               fprintf(stderr,
63+                                               "Warning: .netrc token too long, will be trunctated to %zd characters\n",
64+                                               toklen);
65+                               showwarn = 0;
66+                       }
67+                       continue;
68                }
69+               *cp++ = c;
70+               toklen++;
71        }
72+
73        *cp = 0;
74        if (tokval[0] == 0)
75                return (0);
Note: See TracBrowser for help on using the repository browser.