s3/utils: Check return of talloc_strdup
authorNoel Power <noel.power@suse.com>
Mon, 17 Oct 2022 09:25:00 +0000 (10:25 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 17 Oct 2022 18:46:29 +0000 (18:46 +0000)
followup to e82699fcca3716d9ed0450263fd83f948de8ffbe

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15205

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/utils/pdbedit.c

index eb4f3072df84800cf8610e4b04fc68aabe898719..ede467108bbf8e5e5b54f34271653c6a68dabad2 100644 (file)
@@ -1149,8 +1149,16 @@ int main(int argc, const char **argv)
 
        poptGetArg(pc); /* Drop argv[0], the program name */
 
-       if (user_name == NULL)
-               user_name = talloc_strdup(frame, poptGetArg(pc));
+       if (user_name == NULL) {
+               if (poptPeekArg(pc)) {
+                       user_name = talloc_strdup(frame, poptGetArg(pc));
+                       if (user_name == NULL) {
+                               fprintf(stderr, "out of memory\n");
+                               TALLOC_FREE(frame);
+                               exit(1);
+                       }
+               }
+       }
 
        setparms =      (backend ? BIT_BACKEND : 0) +
                        (verbose ? BIT_VERBOSE : 0) +