Blame SOURCES/netkit-ftp-0.17-token.patch
|
|
4f574c |
diff -rup netkit-ftp-0.17/ftp/ruserpass.c netkit-ftp-0.17-new/ftp/ruserpass.c
|
|
|
4f574c |
--- netkit-ftp-0.17/ftp/ruserpass.c 2012-10-29 15:11:10.593841089 +0100
|
|
|
4f574c |
+++ netkit-ftp-0.17-new/ftp/ruserpass.c 2012-10-29 15:13:14.379822697 +0100
|
|
|
4f574c |
@@ -58,7 +58,8 @@ static int token(void);
|
|
|
4f574c |
#define ID 10
|
|
|
4f574c |
#define MACH 11
|
|
|
4f574c |
|
|
|
4f574c |
-static char tokval[100];
|
|
|
4f574c |
+#define MAXTOKENLEN 4096
|
|
|
4f574c |
+static char tokval[MAXTOKENLEN];
|
|
|
4f574c |
|
|
|
4f574c |
static struct toktab {
|
|
|
4f574c |
const char *tokstr;
|
|
|
4f574c |
@@ -249,13 +250,16 @@ bad:
|
|
|
4f574c |
return(-1);
|
|
|
4f574c |
}
|
|
|
4f574c |
|
|
|
4f574c |
-static
|
|
|
4f574c |
+static
|
|
|
4f574c |
int
|
|
|
4f574c |
token(void)
|
|
|
4f574c |
{
|
|
|
4f574c |
char *cp;
|
|
|
4f574c |
int c;
|
|
|
4f574c |
struct toktab *t;
|
|
|
4f574c |
+ size_t toklen = 0;
|
|
|
4f574c |
+ int showwarn = 1;
|
|
|
4f574c |
+ int quote = 0;
|
|
|
4f574c |
|
|
|
4f574c |
if (feof(cfile))
|
|
|
4f574c |
return (0);
|
|
|
4f574c |
@@ -266,20 +270,32 @@ token(void)
|
|
|
4f574c |
return (0);
|
|
|
4f574c |
cp = tokval;
|
|
|
4f574c |
if (c == '"') {
|
|
|
4f574c |
- while ((c = getc(cfile)) != EOF && c != '"') {
|
|
|
4f574c |
- if (c == '\\')
|
|
|
4f574c |
- c = getc(cfile);
|
|
|
4f574c |
- *cp++ = c;
|
|
|
4f574c |
- }
|
|
|
4f574c |
- } else {
|
|
|
4f574c |
+ quote = 1;
|
|
|
4f574c |
+ }
|
|
|
4f574c |
+ else {
|
|
|
4f574c |
*cp++ = c;
|
|
|
4f574c |
- while ((c = getc(cfile)) != EOF
|
|
|
4f574c |
- && c != '\n' && c != '\t' && c != ' ' && c != ',') {
|
|
|
4f574c |
- if (c == '\\')
|
|
|
4f574c |
- c = getc(cfile);
|
|
|
4f574c |
- *cp++ = c;
|
|
|
4f574c |
+ toklen++;
|
|
|
4f574c |
+ }
|
|
|
4f574c |
+ while ((c = getc(cfile)) != EOF) {
|
|
|
4f574c |
+ if (c == '"')
|
|
|
4f574c |
+ break;
|
|
|
4f574c |
+ if (c == '\\')
|
|
|
4f574c |
+ c = getc(cfile);
|
|
|
4f574c |
+ if (!quote && (c == '\n' || c == '\t' || c == ' ' || c == ','))
|
|
|
4f574c |
+ break;
|
|
|
4f574c |
+ if (toklen >= MAXTOKENLEN) {
|
|
|
4f574c |
+ if (showwarn) {
|
|
|
4f574c |
+ fprintf(stderr,
|
|
|
4f574c |
+ "Warning: .netrc token too long, will be trunctated to %zd characters\n",
|
|
|
4f574c |
+ toklen);
|
|
|
4f574c |
+ showwarn = 0;
|
|
|
4f574c |
+ }
|
|
|
4f574c |
+ continue;
|
|
|
4f574c |
}
|
|
|
4f574c |
+ *cp++ = c;
|
|
|
4f574c |
+ toklen++;
|
|
|
4f574c |
}
|
|
|
4f574c |
+
|
|
|
4f574c |
*cp = 0;
|
|
|
4f574c |
if (tokval[0] == 0)
|
|
|
4f574c |
return (0);
|