]> diplodocus.org Git - nmh/commitdiff
Fix netrc's token()'s bug if backslash escapes EOF.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sat, 22 Oct 2016 17:09:02 +0000 (18:09 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sat, 22 Oct 2016 17:09:02 +0000 (18:09 +0100)
Discard the whole token so the user hopefully investigates.

sbr/ruserpass.c

index 5b65038..f5fc6bd 100644 (file)
@@ -204,8 +204,9 @@ token(char *tokval)
             return TOK_EOF;
 
     while ((c = getc(cfile)) != EOF && c && !strchr(stop, c)) {
             return TOK_EOF;
 
     while ((c = getc(cfile)) != EOF && c && !strchr(stop, c)) {
-        if (c == '\\')
-            c = getc(cfile); /* BUG: What if this is EOF. */
+        if (c == '\\' && (c = getc(cfile)) == EOF)
+            return TOK_EOF; /* Discard whole token. */
+
         *cp++ = c;
         if (cp - tokval > MAX_TOKVAL_SIZE-1) {
             adios(NULL, "credential tokens restricted to length %d",
         *cp++ = c;
         if (cp - tokval > MAX_TOKVAL_SIZE-1) {
             adios(NULL, "credential tokens restricted to length %d",