From eb6dd7dc29a9b89d155d987331aaa79fd4c9a9bb Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 22 Nov 2017 10:43:19 +0100 Subject: [PATCH] s3/smbstatus: add a NULL check Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/utils/status.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source3/utils/status.c b/source3/utils/status.c index abc0d26df53..dd196b64a47 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -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)); } }