]> diplodocus.org Git - nmh/commitdiff
Added check for passing null argument to printf(3) %s directive.
authorDavid Levine <levinedl@acm.org>
Sun, 15 Mar 2020 21:35:55 +0000 (17:35 -0400)
committerDavid Levine <levinedl@acm.org>
Sun, 15 Mar 2020 21:35:55 +0000 (17:35 -0400)
This fixed "directive argument is null" warnings found by gcc
-Wformat-overflow.

sbr/ruserpass.c

index 77b57a7..4b3d81b 100644 (file)
@@ -153,7 +153,7 @@ ruserpass(const char *host, char **aname, char **apass, int flags)
            if ((pp = getpwuid (getuid())) != NULL)
                myname = pp->pw_name;
        }
-       printf("Name (%s:%s): ", host, myname);
+       printf("Name (%s:%s): ", host ? host : "", myname);
 
        if (fgets(tmp, sizeof tmp, stdin) == NULL) {
            advise ("tmp", "fgets");