diff options
author | ikerexxe <ipedrosa@redhat.com> | 2020-06-29 16:06:28 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2020-07-01 09:54:22 +0000 |
commit | 276ad5b8e48aa77c24ef25e18d2e97f66c83d68c (patch) | |
tree | 237ab8b9bc1f6f68e4116a61feebcdebb72edab1 | |
parent | 2bae5daf16d4466185fac89539d653b269a3ea01 (diff) | |
download | pam-276ad5b8e48aa77c24ef25e18d2e97f66c83d68c.tar.gz pam-276ad5b8e48aa77c24ef25e18d2e97f66c83d68c.tar.bz2 pam-276ad5b8e48aa77c24ef25e18d2e97f66c83d68c.zip |
pam_loginuid: fix unlikely negative 3rd argument of strncmp on error path
[ldv: rewrote commit message]
* modules/pam_loginuid/pam_loginuid.c (set_loginuid): Do not pass to
strncmp the return value of pam_modutil_read in an unlikely case when
the latter fails to read from /proc/self/uid_map.
-rw-r--r-- | modules/pam_loginuid/pam_loginuid.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/pam_loginuid/pam_loginuid.c b/modules/pam_loginuid/pam_loginuid.c index 62dd3d59..6f5a6380 100644 --- a/modules/pam_loginuid/pam_loginuid.c +++ b/modules/pam_loginuid/pam_loginuid.c @@ -65,7 +65,7 @@ static int set_loginuid(pam_handle_t *pamh, uid_t uid) fd = open("/proc/self/uid_map", O_RDONLY); if (fd >= 0) { count = pam_modutil_read(fd, uid_map, sizeof(uid_map)); - if (strncmp(uid_map, host_uid_map, count) != 0) + if (count <= 0 || strncmp(uid_map, host_uid_map, count) != 0) rc = PAM_IGNORE; close(fd); } |