aboutsummaryrefslogtreecommitdiff
path: root/libpam
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2024-01-04 19:18:34 +0100
committerDmitry V. Levin <ldv@strace.io>2024-01-04 18:18:34 +0000
commitf19cd01ad56306e05145ff51fa392163405b8516 (patch)
tree5739d0f81cf93f8b91a6fd7e21ea884d74376f00 /libpam
parent3c71b368dd52e6acd2e887a8b8317a223b3fce4e (diff)
downloadpam-f19cd01ad56306e05145ff51fa392163405b8516.tar.gz
pam-f19cd01ad56306e05145ff51fa392163405b8516.tar.bz2
pam-f19cd01ad56306e05145ff51fa392163405b8516.zip
libpam: enclose function macros
Avoid potential dangling-else issues by wrapping macros inside a while loop.
Diffstat (limited to 'libpam')
-rw-r--r--libpam/pam_item.c4
-rw-r--r--libpam/pam_private.h10
2 files changed, 8 insertions, 6 deletions
diff --git a/libpam/pam_item.c b/libpam/pam_item.c
index a27c680b..ad736a4f 100644
--- a/libpam/pam_item.c
+++ b/libpam/pam_item.c
@@ -13,7 +13,7 @@
#include <syslog.h>
#define TRY_SET(X, Y) \
-{ \
+do { \
if ((X) != (Y)) { \
char *_TMP_ = _pam_strdup(Y); \
if (_TMP_ == NULL && (Y) != NULL) \
@@ -21,7 +21,7 @@
free(X); \
(X) = _TMP_; \
} \
-}
+} while(0)
/* functions */
diff --git a/libpam/pam_private.h b/libpam/pam_private.h
index df6872fa..f9dd6223 100644
--- a/libpam/pam_private.h
+++ b/libpam/pam_private.h
@@ -289,10 +289,12 @@ void _pam_parse_control(int *control_array, char *tok);
*/
#define IF_NO_PAMH(pamh,ERR) \
-if ((pamh) == NULL) { \
- syslog(LOG_ERR, _PAM_SYSTEM_LOG_PREFIX " %s: NULL pam handle passed", __FUNCTION__); \
- return ERR; \
-}
+do { \
+ if ((pamh) == NULL) { \
+ syslog(LOG_ERR, _PAM_SYSTEM_LOG_PREFIX " %s: NULL pam handle passed", __FUNCTION__); \
+ return ERR; \
+ } \
+} while(0)
/*
* include some helpful macros