pam_winbind: Return if we do not have a domain
authorAndreas Schneider <asn@samba.org>
Fri, 17 Feb 2017 10:53:52 +0000 (11:53 +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>
nsswitch/pam_winbind.c

index 859101fcd794f69bd41a5d134c714e9c67a0bb02..746b157919ef079a9ff0fccd9cb7fdd6118910a1 100644 (file)
@@ -2479,10 +2479,14 @@ static char* winbind_upn_to_username(struct pwb_context *ctx,
        if (!name) {
                return NULL;
        }
-       if ((p = strchr(name, '@')) != NULL) {
-               *p = 0;
-               domain = p + 1;
+
+       p = strchr(name, '@');
+       if (p == NULL) {
+               TALLOC_FREE(name);
+               return NULL;
        }
+       *p = '\0';
+       domain = p + 1;
 
        /* Convert the UPN to a SID */