Bug 9807 - wbinfo: fix segfault in wbinfo_pam_logon
authorDavid Disseldorp <ddiss@samba.org>
Wed, 17 Apr 2013 17:39:12 +0000 (10:39 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 17 Apr 2013 19:29:29 +0000 (21:29 +0200)
wbinfo_pam_logon() incorrectly assumes that wbcLogonUser() always
returns an allocated wbcAuthErrorInfo struct on failure.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Apr 17 21:29:29 CEST 2013 on sn-devel-104

nsswitch/wbinfo.c

index cd6de34fd5e9f3a8b409bee3bc6d4c0d183c2dc6..8b178598edc66d0e708e080dbfcc0bbaff4f8f14 100644 (file)
@@ -1749,7 +1749,7 @@ static bool wbinfo_pam_logon(char *username)
 {
        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
        struct wbcLogonUserParams params;
-       struct wbcAuthErrorInfo *error;
+       struct wbcAuthErrorInfo *error = NULL;
        char *s = NULL;
        char *p = NULL;
        TALLOC_CTX *frame = talloc_tos();
@@ -1800,16 +1800,15 @@ static bool wbinfo_pam_logon(char *username)
        d_printf("plaintext password authentication %s\n",
                 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
 
-       if (!WBC_ERROR_IS_OK(wbc_status)) {
+       if (!WBC_ERROR_IS_OK(wbc_status) && (error != NULL)) {
                d_fprintf(stderr,
                          "error code was %s (0x%x)\nerror message was: %s\n",
                          error->nt_string,
                          (int)error->nt_status,
                          error->display_string);
                wbcFreeMemory(error);
-               return false;
        }
-       return true;
+       return WBC_ERROR_IS_OK(wbc_status);
 }
 
 /* Save creds with winbind */