nsswitch: Handle possible NULL return value of getprogname()
authorAndreas Schneider <asn@samba.org>
Mon, 12 Nov 2018 14:47:46 +0000 (15:47 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 13 Nov 2018 06:37:25 +0000 (07:37 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
nsswitch/wb_common.c

index 6eea32c..f2672fb 100644 (file)
@@ -89,14 +89,19 @@ void winbind_set_client_name(const char *name)
 static const char *winbind_get_client_name(void)
 {
        if (client_name[0] == '\0') {
+               const char *progname = getprogname();
                int len;
 
+               if (progname == NULL) {
+                       progname = "<unknown>";
+               }
+
                len = snprintf(client_name,
                               sizeof(client_name),
                               "%s",
-                              getprogname());
+                              progname);
                if (len <= 0) {
-                       return "<unkonwn>";
+                       return progname;
                }
        }