X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/6911ccf8fcd1ad179801d517f48817ea8c22b4a3..1dd139e04f59bbfa3a310c2776c4bb2e2fdf1fdd:/sbr/ruserpass.c diff --git a/sbr/ruserpass.c b/sbr/ruserpass.c index 5b650389..1e43571e 100644 --- a/sbr/ruserpass.c +++ b/sbr/ruserpass.c @@ -1,4 +1,5 @@ -/* +/* ruserpass.c -- parse .netrc-format file. + * * Portions of this code are * Copyright (c) 1985 Regents of the University of California. * All rights reserved. @@ -80,7 +81,7 @@ ruserpass(const char *host, char **aname, char **apass, int flags) switch(t) { case DEFAULT: usedefault = 1; - /* FALL THROUGH */ + /* FALLTHRU */ case MACH: if (!usedefault) { @@ -107,8 +108,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); + inform("group or other permissions, %#o, " + "forbidden: %s", stb.st_mode, credentials_file); adios(NULL, "Remove password or correct file " "permissions."); } @@ -147,10 +148,10 @@ 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'); + trim_suffix_c(tmp, '\n'); if (*tmp != '\0' || myname == NULL) { myname = tmp; } @@ -204,8 +205,9 @@ token(char *tokval) 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",