Skip to content

Commit ada47ee

Browse files
committed
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
1 parent 63ebe35 commit ada47ee

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

plugins/sudoers/cvtsudoers_pwutil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ cvtsudoers_make_grlist_item(const struct passwd *pw, char * const *unused1)
421421
}
422422

423423
#ifdef _SC_LOGIN_NAME_MAX
424-
groupname_len = MAX((size_t)sysconf(_SC_LOGIN_NAME_MAX), 32);
424+
groupname_len = (size_t)MAX(sysconf(_SC_LOGIN_NAME_MAX), 32);
425425
#else
426426
groupname_len = MAX(LOGIN_NAME_MAX, 32);
427427
#endif

plugins/sudoers/pwutil_impl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ PREFIX(make_grlist_item)(const struct passwd *pw, char * const *unused1)
381381
}
382382

383383
#ifdef _SC_LOGIN_NAME_MAX
384-
groupname_len = MAX((size_t)sysconf(_SC_LOGIN_NAME_MAX), 32);
384+
groupname_len = (size_t)MAX(sysconf(_SC_LOGIN_NAME_MAX), 32);
385385
#else
386386
groupname_len = MAX(LOGIN_NAME_MAX, 32);
387387
#endif

0 commit comments

Comments
 (0)