pam_winbind: Fix segfault caused by invalid configuration options
authorGarming Sam <garming@catalyst.net.nz>
Mon, 16 Dec 2013 03:50:37 +0000 (16:50 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 14 Jan 2014 22:44:26 +0000 (23:44 +0100)
This is a better fix for 8564 and will allow ec0f51b200d6e5b99bbd872e169621c17f33524c to be reverted.

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

Pair-programmed-with: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: David Disseldorp <ddiss@samba.org>
nsswitch/pam_winbind.c

index cd5e7ba206ee25c68bcb71fefde5e076da568b29..9a5367ba2e224fe45d5aa913eb67e4d82d9f544c 100644 (file)
@@ -140,7 +140,7 @@ static const char *_pam_error_code_str(int err)
 #define _PAM_LOG_FUNCTION_LEAVE(function, ctx, retval) \
        do { \
                _pam_log_debug(ctx, LOG_DEBUG, "[pamh: %p] LEAVE: " \
-                              function " returning %d (%s)", ctx->pamh, retval, \
+                              function " returning %d (%s)", ctx ? ctx->pamh : NULL, retval, \
                               _pam_error_code_str(retval)); \
                _pam_log_state(ctx); \
        } while (0)
@@ -261,7 +261,7 @@ static void _pam_log_debug(struct pwb_context *r, int err, const char *format, .
 {
        va_list args;
 
-       if (!_pam_log_is_debug_enabled(r->ctrl)) {
+       if (!r || !_pam_log_is_debug_enabled(r->ctrl)) {
                return;
        }
 
@@ -348,7 +348,7 @@ static char *iniparser_getstring_nonempty(dictionary *d, char *key, char *def)
 
 static void _pam_log_state(struct pwb_context *ctx)
 {
-       if (!_pam_log_is_debug_state_enabled(ctx->ctrl)) {
+       if (!ctx || !_pam_log_is_debug_state_enabled(ctx->ctrl)) {
                return;
        }