From 2e677446e35898f1539e6522a826d392c6abde50 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Tue, 2 Jan 2024 21:13:07 +0100 Subject: pam_unix: use size_t instead of int for sizes Also rename buflen to retlen, since it is not associated with the variable buf, but ret. Signed-off-by: Tobias Stoeckmann --- modules/pam_unix/support.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules/pam_unix') diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c index 49807873..bdba3ce5 100644 --- a/modules/pam_unix/support.c +++ b/modules/pam_unix/support.c @@ -348,9 +348,9 @@ int _unix_getpwnam(pam_handle_t *pamh, const char *name, { FILE *passwd; char buf[16384]; - int matched = 0, buflen; + int matched = 0; char *slogin, *spasswd, *suid, *sgid, *sgecos, *shome, *sshell, *p; - size_t userlen; + size_t retlen, userlen; memset(buf, 0, sizeof(buf)); @@ -438,17 +438,17 @@ int _unix_getpwnam(pam_handle_t *pamh, const char *name, } *sshell++ = '\0'; - buflen = sizeof(struct passwd) + + retlen = sizeof(struct passwd) + strlen(slogin) + 1 + strlen(spasswd) + 1 + strlen(sgecos) + 1 + strlen(shome) + 1 + strlen(sshell) + 1; - *ret = malloc(buflen); + *ret = malloc(retlen); if (*ret == NULL) { return matched; } - memset(*ret, '\0', buflen); + memset(*ret, '\0', retlen); (*ret)->pw_uid = strtol(suid, &p, 10); if ((strlen(suid) == 0) || (*p != '\0')) { -- cgit v1.2.3