2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-30 05:48:18 +00:00

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.

--HG--
branch : 1.9
This commit is contained in:
Todd C. Miller 2023-12-28 09:00:49 -07:00
parent 63ebe354c9
commit ada47ee108
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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