summaryrefslogtreecommitdiff
path: root/modules/pam_motd
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-04-26 11:12:59 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-04-26 11:12:59 +0000
commit70ee22ba4414b47dcd4ea2dfb8f3ba462b38718d (patch)
tree7994d78e289868dd62a2083c0ccec781a2e546c1 /modules/pam_motd
parent4efb14c2ae1c2cf8c0aba4f626a0942295017f40 (diff)
pam_motd: fix misleading error diagnostics
Do not invoke calloc with the first argument equal to zero as the return value can be NULL which is undistinguishable from memory allocation error. * modules/pam_motd/pam_motd.c (try_to_display_directories_with_overrides): Skip if there are no directory entries (dirscans_size_total == 0). Fixes: f9c9c721 ("pam_motd: Support multiple motd paths specified, with filename overrides (#69)")
Diffstat (limited to 'modules/pam_motd')
-rw-r--r--modules/pam_motd/pam_motd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/pam_motd/pam_motd.c b/modules/pam_motd/pam_motd.c
index 3870d997..f0cd317d 100644
--- a/modules/pam_motd/pam_motd.c
+++ b/modules/pam_motd/pam_motd.c
@@ -224,6 +224,9 @@ static void try_to_display_directories_with_overrides(pam_handle_t *pamh,
dirscans_size_total += dirscans_sizes[i];
}
+ if (dirscans_size_total == 0)
+ goto out;
+
/* Allocate space for all file names found in the directories, including duplicates. */
if ((dirnames_all = calloc(dirscans_size_total, sizeof(char *))) == NULL) {
pam_syslog(pamh, LOG_CRIT, "pam_motd: failed to allocate dirname array");