- Clean up previous gr_add use malloc instead of calloc
- Fix tinderbox error Submitted by: db
This commit is contained in:
parent
0c50344969
commit
2bfeb4fe75
@ -482,7 +482,7 @@ gr_dup(const struct group *gr)
|
|||||||
* Add a new member name to a struct group.
|
* Add a new member name to a struct group.
|
||||||
*/
|
*/
|
||||||
struct group *
|
struct group *
|
||||||
gr_add(struct group *gr, const char *newmember)
|
gr_add(struct group *gr, char *newmember)
|
||||||
{
|
{
|
||||||
size_t mlen;
|
size_t mlen;
|
||||||
int num_mem=0;
|
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 */
|
/* Allocate enough for current pointers + 1 more and NULL marker */
|
||||||
mlen = (num_mem + 2) * sizeof(*gr->gr_mem);
|
mlen = (num_mem + 2) * sizeof(*gr->gr_mem);
|
||||||
if ((members = calloc(1, mlen )) == NULL) {
|
if ((members = malloc(mlen)) == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
memcpy(members, gr->gr_mem, num_mem * sizeof(*gr->gr_mem));
|
memcpy(members, gr->gr_mem, num_mem * sizeof(*gr->gr_mem));
|
||||||
members[num_mem++] = (char *)newmember;
|
members[num_mem++] = newmember;
|
||||||
members[num_mem] = NULL;
|
members[num_mem] = NULL;
|
||||||
gr->gr_mem = members;
|
gr->gr_mem = members;
|
||||||
newgr = gr_dup(gr);
|
newgr = gr_dup(gr);
|
||||||
if (newgr == NULL)
|
if (newgr == NULL)
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
|
|
||||||
free(members);
|
free(members);
|
||||||
return (newgr);
|
return (newgr);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ int gr_copy(int __ffd, int _tfd, const struct group *_gr,
|
|||||||
struct group *
|
struct group *
|
||||||
gr_dup(const struct group *_gr);
|
gr_dup(const struct group *_gr);
|
||||||
struct group *
|
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);
|
int gr_equal(const struct group *_gr1, const struct group *_gr2);
|
||||||
void gr_fini(void);
|
void gr_fini(void);
|
||||||
int gr_init(const char *_dir, const char *_master);
|
int gr_init(const char *_dir, const char *_master);
|
||||||
|
Loading…
Reference in New Issue
Block a user