s3:lib: Do not segfault if username is NULL
authorAndreas Schneider <asn@samba.org>
Fri, 17 Feb 2017 09:08:17 +0000 (10:08 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 23 Feb 2017 02:18:10 +0000 (03:18 +0100)
Found by covscan.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/util_cmdline.c

index 6c98b44ebd27ae40bdab53e879bb0a093769e0a5..ad51a4f5217e95dff788667bf7249de1828d5c5a 100644 (file)
@@ -112,11 +112,14 @@ void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
 {
        const char *new_val = NULL;
 
+       if (username == NULL) {
+               return;
+       }
        cli_credentials_parse_string(auth_info->creds,
                                     username,
                                     CRED_SPECIFIED);
        new_val = cli_credentials_get_username(auth_info->creds);
-       if (username != NULL && new_val == NULL) {
+       if (new_val == NULL) {
                exit(ENOMEM);
        }