From e4057faca239b7ed9e2402da548b6965b284445b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 28 Dec 2023 09:00:49 -0700 Subject: [PATCH] Properly handle sysconf(_SC_LOGIN_NAME_MAX) returning -1 on failure. The cast to size_t needs to be outside the MAX() macro or the -1 will get cast to unsigned. --- plugins/sudoers/cvtsudoers_pwutil.c | 2 +- plugins/sudoers/pwutil_impl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/sudoers/cvtsudoers_pwutil.c b/plugins/sudoers/cvtsudoers_pwutil.c index 2a0dc0504..35ccbdd4a 100644 --- a/plugins/sudoers/cvtsudoers_pwutil.c +++ b/plugins/sudoers/cvtsudoers_pwutil.c @@ -421,7 +421,7 @@ cvtsudoers_make_grlist_item(const struct passwd *pw, char * const *unused1) } #ifdef _SC_LOGIN_NAME_MAX - groupname_len = MAX((size_t)sysconf(_SC_LOGIN_NAME_MAX), 32); + groupname_len = (size_t)MAX(sysconf(_SC_LOGIN_NAME_MAX), 32); #else groupname_len = MAX(LOGIN_NAME_MAX, 32); #endif diff --git a/plugins/sudoers/pwutil_impl.c b/plugins/sudoers/pwutil_impl.c index e8c328f60..a2e3394e4 100644 --- a/plugins/sudoers/pwutil_impl.c +++ b/plugins/sudoers/pwutil_impl.c @@ -381,7 +381,7 @@ PREFIX(make_grlist_item)(const struct passwd *pw, char * const *unused1) } #ifdef _SC_LOGIN_NAME_MAX - groupname_len = MAX((size_t)sysconf(_SC_LOGIN_NAME_MAX), 32); + groupname_len = (size_t)MAX(sysconf(_SC_LOGIN_NAME_MAX), 32); #else groupname_len = MAX(LOGIN_NAME_MAX, 32); #endif