Patch for coredump with missing arg from "Bradley W. Langhorst" <brad@langhorst.com>
authorJeremy Allison <jra@samba.org>
Sat, 28 Dec 2002 01:23:34 +0000 (01:23 +0000)
committerJeremy Allison <jra@samba.org>
Sat, 28 Dec 2002 01:23:34 +0000 (01:23 +0000)
Jeremy.
(This used to be commit 5914c38a54fcfdb007352b152dc2206708d59af6)

source3/utils/pdbedit.c

index 45a63c4b64cd81f100c6f100fa6c755bed5cea2e..773af7c79a0693bd86440702d4a89e0de68d7805 100644 (file)
@@ -495,7 +495,14 @@ int main (int argc, char **argv)
        poptGetArg(pc); /* Drop argv[0], the program name */
 
        if (user_name == NULL) {
-               user_name = poptGetArg(pc);
+               if (poptPeekArg(pc) == NULL) {
+                       fprintf(stderr, "Can't use pdbedit without a username\n");
+                       poptPrintHelp(pc, stderr, 0);
+                       exit(1);
+               } else {
+                       /*Don't try to duplicate a null string */
+                       user_name = strdup(poptGetArg(pc));
+               }
        }
 
        if (!lp_load(dyn_CONFIGFILE,True,False,False)) {