diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2020-04-26 11:12:59 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2020-04-26 11:12:59 +0000 |
commit | b77aa28f46596773110e842d79b65d3fdce9ed22 (patch) | |
tree | 6de2203aa2779ccf51512138eb55df2550ad1936 /modules | |
parent | 48090491ef704ef2c61951b7dcbcd4373dcb5c5d (diff) | |
download | pam-b77aa28f46596773110e842d79b65d3fdce9ed22.tar.gz pam-b77aa28f46596773110e842d79b65d3fdce9ed22.tar.bz2 pam-b77aa28f46596773110e842d79b65d3fdce9ed22.zip |
pam_motd: fix NULL dereference on error path
* modules/pam_motd/pam_motd.c
(try_to_display_directories_with_overrides): Do not access
elements of dirscans_sizes array if dirscans_sizes == NULL
due to an earlier memory allocation error.
Fixes: f9c9c721 ("pam_motd: Support multiple motd paths specified, with filename overrides (#69)")
Diffstat (limited to 'modules')
-rw-r--r-- | modules/pam_motd/pam_motd.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/pam_motd/pam_motd.c b/modules/pam_motd/pam_motd.c index a8887ec1..49886d1a 100644 --- a/modules/pam_motd/pam_motd.c +++ b/modules/pam_motd/pam_motd.c @@ -281,15 +281,16 @@ static void try_to_display_directories_with_overrides(pam_handle_t *pamh, out: _pam_drop(dirnames_all); - for (i = 0; i < num_motd_dirs; i++) { - unsigned int j; + if (dirscans_sizes != NULL) { + for (i = 0; i < num_motd_dirs; i++) { + unsigned int j; - for (j = 0; j < dirscans_sizes[i]; j++) { - _pam_drop(dirscans[i][j]); + for (j = 0; j < dirscans_sizes[i]; j++) + _pam_drop(dirscans[i][j]); + _pam_drop(dirscans[i]); } - _pam_drop(dirscans[i]); + _pam_drop(dirscans_sizes); } - _pam_drop(dirscans_sizes); _pam_drop(dirscans); } |