From e4deb071bdf0b1c5e840a38d268e178539c763e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 24 Mar 2017 14:45:58 +0000 Subject: [PATCH] Restore the NULL check that was removed in upstream r913. It is not unreasonable to call pam_end() with a NULL pamh in error handling code. Reported by: rwatson --- contrib/openpam/include/security/pam_appl.h | 3 +-- contrib/openpam/lib/libpam/pam_end.c | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/openpam/include/security/pam_appl.h b/contrib/openpam/include/security/pam_appl.h index 8edf897dfe7e..5533bed233b9 100644 --- a/contrib/openpam/include/security/pam_appl.h +++ b/contrib/openpam/include/security/pam_appl.h @@ -72,8 +72,7 @@ pam_close_session(pam_handle_t *_pamh, int pam_end(pam_handle_t *_pamh, - int _status) - OPENPAM_NONNULL((1)); + int _status); int pam_get_data(const pam_handle_t *_pamh, diff --git a/contrib/openpam/lib/libpam/pam_end.c b/contrib/openpam/lib/libpam/pam_end.c index c855b59c4885..d1b3ad589845 100644 --- a/contrib/openpam/lib/libpam/pam_end.c +++ b/contrib/openpam/lib/libpam/pam_end.c @@ -60,6 +60,8 @@ pam_end(pam_handle_t *pamh, int i; ENTER(); + if (pamh == NULL) + RETURNC(PAM_SYSTEM_ERR); /* clear module data */ while ((dp = pamh->module_data) != NULL) {