s3/smbstatus: add a NULL check
authorRalph Boehme <slow@samba.org>
Wed, 22 Nov 2017 09:43:19 +0000 (10:43 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 27 Nov 2017 21:08:17 +0000 (22:08 +0100)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/utils/status.c

index abc0d26df53b191be0c0f1a348469629720ef384..dd196b64a470c664caab098f045eb1d59ce2f936 100644 (file)
@@ -386,7 +386,12 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
                if (numeric_only) {
                        fstr_sprintf(uid_str, "%u", (unsigned int)session->uid);
                } else {
-                       fstrcpy(uid_str, uidtoname(session->uid));
+                       const char *uid_name = uidtoname(session->uid);
+
+                       if (uid_name == NULL) {
+                               return -1;
+                       }
+                       fstrcpy(uid_str, uid_name);
                }
        }
 
@@ -396,6 +401,11 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
                if (numeric_only) {
                        fstr_sprintf(gid_str, "%u", (unsigned int)session->gid);
                } else {
+                       const char *gid_name = gidtoname(session->gid);
+
+                       if (gid_name == NULL) {
+                               return -1;
+                       }
                        fstrcpy(gid_str, gidtoname(session->gid));
                }
        }