diff options
author | bapt <bapt@FreeBSD.org> | 2012-12-27 16:51:29 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2012-12-27 16:51:29 +0000 |
commit | 247c2a40864f8d06b2dcc9ee18b183e22b3b29f7 (patch) | |
tree | 79a06b2e9d95fe1bd3b2bdd4f49e83f7e57b33d5 /lib/libutil | |
parent | a7f43aa14667a3c708d38f382f07361c334894eb (diff) | |
download | FreeBSD-src-247c2a40864f8d06b2dcc9ee18b183e22b3b29f7.zip FreeBSD-src-247c2a40864f8d06b2dcc9ee18b183e22b3b29f7.tar.gz |
- Clean up previous gr_add use malloc instead of calloc
- Fix tinderbox error
Submitted by: db
Diffstat (limited to 'lib/libutil')
-rw-r--r-- | lib/libutil/gr_util.c | 7 | ||||
-rw-r--r-- | lib/libutil/libutil.h | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/lib/libutil/gr_util.c b/lib/libutil/gr_util.c index 90062eb..0cd8055 100644 --- a/lib/libutil/gr_util.c +++ b/lib/libutil/gr_util.c @@ -482,7 +482,7 @@ gr_dup(const struct group *gr) * Add a new member name to a struct group. */ struct group * -gr_add(struct group *gr, const char *newmember) +gr_add(struct group *gr, char *newmember) { size_t mlen; int num_mem=0; @@ -502,18 +502,17 @@ gr_add(struct group *gr, const char *newmember) } /* Allocate enough for current pointers + 1 more and NULL marker */ mlen = (num_mem + 2) * sizeof(*gr->gr_mem); - if ((members = calloc(1, mlen )) == NULL) { + if ((members = malloc(mlen)) == NULL) { errno = ENOMEM; return (NULL); } memcpy(members, gr->gr_mem, num_mem * sizeof(*gr->gr_mem)); - members[num_mem++] = (char *)newmember; + members[num_mem++] = newmember; members[num_mem] = NULL; gr->gr_mem = members; newgr = gr_dup(gr); if (newgr == NULL) errno = ENOMEM; - free(members); return (newgr); } diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h index fcd74e1..b1b2405 100644 --- a/lib/libutil/libutil.h +++ b/lib/libutil/libutil.h @@ -167,7 +167,7 @@ int gr_copy(int __ffd, int _tfd, const struct group *_gr, struct group * gr_dup(const struct group *_gr); struct group * - gr_add(struct group *_gr, const char *_newmember); + gr_add(struct group *_gr, char *_newmember); int gr_equal(const struct group *_gr1, const struct group *_gr2); void gr_fini(void); int gr_init(const char *_dir, const char *_master); |