[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
mgetgroups realloc issues
From: |
Pádraig Brady |
Subject: |
mgetgroups realloc issues |
Date: |
Wed, 15 Apr 2009 17:24:43 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Hi,
In regard to the realloc() introduced to mgetgroups.c,
I'm not exactly sure but I think the diff below is required
to handle realloc(,0) on glibc.
I.E. I think a double free would have been done and an error
reported if max_n_groups == 0 (which I presume is possible)?
diff --git a/gl/lib/mgetgroups.c b/gl/lib/mgetgroups.c
index 736dd87..d841044 100644
--- a/gl/lib/mgetgroups.c
+++ b/gl/lib/mgetgroups.c
@@ -91,7 +91,8 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T
**groups)
if (ng < 0 && last_n_groups == max_n_groups)
max_n_groups *= 2;
- if ((h = realloc_groupbuf (g, max_n_groups)) == NULL)
+ h = realloc_groupbuf (g, max_n_groups);
+ if (max_n_groups && h == NULL)
{
int saved_errno = errno;
free (g);
Also I think this may be necessary to ensure that we're
using the glibc flavour of realloc() ?
diff --git a/gl/modules/mgetgroups b/gl/modules/mgetgroups
index 8bce53a..53c8a8d 100644
--- a/gl/modules/mgetgroups
+++ b/gl/modules/mgetgroups
@@ -9,6 +9,7 @@ m4/mgetgroups.m4
Depends-on:
getugroups
xalloc
+realloc
configure.ac:
gl_MGETGROUPS
cheers,
Pádraig.
For my own reference here is some info on the realloc(,0) issue:
http://bytes.com/groups/c/586145-realloc-zero-bytes
- mgetgroups realloc issues,
Pádraig Brady <=