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.
This commit is contained in:
Todd C. Miller
2023-12-28 09:00:49 -07:00
parent ad4dc22d5a
commit e4057faca2
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