summaryrefslogtreecommitdiff
path: root/libpam/pam_handlers.c
diff options
context:
space:
mode:
authorSam Hartman <hartmans@debian.org>2023-09-11 14:09:57 -0600
committerSam Hartman <hartmans@debian.org>2023-09-11 14:09:57 -0600
commite9aa2ef52a423a3a33299bf7e8715eb5bd76ea67 (patch)
tree8b1bd3f4fc01ef0261a13d75cf48be9002480aaf /libpam/pam_handlers.c
parent99d0d1c5c4f07332daa86e73981267a761bc966e (diff)
parentbf07335a19d6192adaf4b1a817d2101ee0bad134 (diff)
New upstream version 1.5.3
Diffstat (limited to 'libpam/pam_handlers.c')
-rw-r--r--libpam/pam_handlers.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/libpam/pam_handlers.c b/libpam/pam_handlers.c
index ffa5e4ae..1f1917b5 100644
--- a/libpam/pam_handlers.c
+++ b/libpam/pam_handlers.c
@@ -281,7 +281,7 @@ _pam_open_config_file(pam_handle_t *pamh
, char **path
, FILE **file)
{
- const char *pamd_dirs[] = { PAM_CONFIG_DF, PAM_CONFIG_DIST_DF
+ const char *const pamd_dirs[] = { PAM_CONFIG_DF, PAM_CONFIG_DIST_DF
#ifdef VENDORDIR
, PAM_CONFIG_DIST2_DF
#endif
@@ -317,10 +317,12 @@ _pam_open_config_file(pam_handle_t *pamh
}
for (i = 0; i < PAM_ARRAY_SIZE(pamd_dirs); i++) {
- if (asprintf (&p, pamd_dirs[i], service) < 0) {
+ DIAG_PUSH_IGNORE_FORMAT_NONLITERAL
+ if (asprintf (&p, pamd_dirs[i], service) < 0) {
pam_syslog(pamh, LOG_CRIT, "asprintf failed");
return PAM_BUF_ERR;
}
+ DIAG_POP_IGNORE_FORMAT_NONLITERAL
D(("opening %s", p));
f = fopen(p, "r");
@@ -889,8 +891,8 @@ int _pam_add_handler(pam_handle_t *pamh
handler_p = &((*handler_p)->next);
}
- if ((*handler_p = malloc(sizeof(struct handler))) == NULL) {
- pam_syslog(pamh, LOG_CRIT, "cannot malloc struct handler #1");
+ if ((*handler_p = calloc(1, sizeof(struct handler))) == NULL) {
+ pam_syslog(pamh, LOG_CRIT, "cannot allocate struct handler #1");
return (PAM_ABORT);
}
@@ -904,8 +906,6 @@ int _pam_add_handler(pam_handle_t *pamh
(*handler_p)->argv = argv; /* not a copy */
if (((*handler_p)->mod_name = extract_modulename(mod_path)) == NULL)
return PAM_ABORT;
- (*handler_p)->grantor = 0;
- (*handler_p)->next = NULL;
/* some of the modules have a second calling function */
if (handler_p2) {
@@ -914,8 +914,8 @@ int _pam_add_handler(pam_handle_t *pamh
handler_p2 = &((*handler_p2)->next);
}
- if ((*handler_p2 = malloc(sizeof(struct handler))) == NULL) {
- pam_syslog(pamh, LOG_CRIT, "cannot malloc struct handler #2");
+ if ((*handler_p2 = calloc(1, sizeof(struct handler))) == NULL) {
+ pam_syslog(pamh, LOG_CRIT, "cannot allocate struct handler #2");
return (PAM_ABORT);
}
@@ -933,13 +933,9 @@ int _pam_add_handler(pam_handle_t *pamh
return (PAM_ABORT);
}
memcpy((*handler_p2)->argv, argv, argvlen);
- } else {
- (*handler_p2)->argv = NULL; /* no arguments */
}
if (((*handler_p2)->mod_name = extract_modulename(mod_path)) == NULL)
return PAM_ABORT;
- (*handler_p2)->grantor = 0;
- (*handler_p2)->next = NULL;
}
D(("_pam_add_handler: returning successfully"));
@@ -1037,7 +1033,7 @@ void _pam_free_handlers_aux(struct handler **hp)
_pam_drop(h->argv); /* This is all allocated in a single chunk */
_pam_drop(h->mod_name);
h = h->next;
- memset(last, 0, sizeof(*last));
+ pam_overwrite_object(last);
free(last);
}