X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/760caf0926e2dcc8931b631f07d2cb091922a295..27df20759b4af4267ece906d26d1e9dbbf5e596f:/sbr/ruserpass.c diff --git a/sbr/ruserpass.c b/sbr/ruserpass.c index fb786d0a..1d946fa2 100644 --- a/sbr/ruserpass.c +++ b/sbr/ruserpass.c @@ -107,8 +107,8 @@ ruserpass(const char *host, char **aname, char **apass, int flags) (stb.st_mode & 077) != 0) { /* We make this a fatal error to force the user to correct it. */ - advise(NULL, "Error - file %s must not be world or " - "group readable.", credentials_file); + advise(NULL, "group or other permissions, %#o, " + "forbidden: %s", stb.st_mode, credentials_file); adios(NULL, "Remove password or correct file " "permissions."); } @@ -147,7 +147,7 @@ ruserpass(const char *host, char **aname, char **apass, int flags) } printf("Name (%s:%s): ", host, myname); - if (fgets(tmp, sizeof(tmp) - 1, stdin) == NULL) { + if (fgets(tmp, sizeof tmp, stdin) == NULL) { advise ("tmp", "fgets"); } TrimSuffixC(tmp, '\n'); @@ -199,11 +199,14 @@ token(char *tokval) * separators. */ stop = "\""; else - *cp++ = c; /* BUG: If a backslash then it doesn't escape. */ + /* Might be backslash. Get it again later. It's handled then. */ + if (ungetc(c, cfile) == EOF) + 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",