Jim Meyering <[EMAIL PROTECTED]> wrote: > "James Youngman" <[EMAIL PROTECTED]> wrote: >> On Fri, Feb 22, 2008 at 9:04 AM, Jim Meyering <[EMAIL PROTECTED]> wrote: > ... >>> + h = realloc (g, max_n_groups * sizeof *h); >> >> Shouldn't realloc here be xnrealloc? > > No. This function is intended to be usable from a library. > I.e., no fair calling exit, which xnrealloc does when it fails. > > Also, the function header comment says what happens > when it fails, and "exit" is not mentioned.
But I suspect your point is that I need to check for overflow. That's true. I'm adding this: diff --git a/gl/lib/mgetgroups.c b/gl/lib/mgetgroups.c index 317cc7c..ba8818e 100644 --- a/gl/lib/mgetgroups.c +++ b/gl/lib/mgetgroups.c @@ -101,8 +101,8 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups) /* When getgrouplist fails, it guarantees that max_n_groups reflects the new number of groups. */ - h = realloc (g, max_n_groups * sizeof *h); - if (h == NULL) + if (xalloc_oversized (max_n_groups, sizeof *h) + || (h = realloc (g, max_n_groups * sizeof *h) == NULL)) { int saved_errno = errno; free (g); _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils