diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-11-04 07:50:48 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-11-04 07:50:48 +0000 |
| commit | cb07b25a192ea00807c9109284ca7e2b26cd713e (patch) | |
| tree | a8591c164d69b5435eb5642619084f0464a94143 /lib/libutil | |
| parent | e1316e0caef9c5bab535183fe2a5ffa755007bd6 (diff) | |
Notes
Diffstat (limited to 'lib/libutil')
| -rw-r--r-- | lib/libutil/gr_util.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/libutil/gr_util.c b/lib/libutil/gr_util.c index 6f7450778f12..465efd982423 100644 --- a/lib/libutil/gr_util.c +++ b/lib/libutil/gr_util.c @@ -170,14 +170,21 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr) size_t len; int eof, readlen; - sgr = gr; + if (old_gr == NULL && gr == NULL) + return(-1); + + sgr = old_gr; + /* deleting a group */ if (gr == NULL) { line = NULL; - if (old_gr == NULL) + } else { + if ((line = gr_make(gr)) == NULL) return (-1); - sgr = old_gr; - } else if ((line = gr_make(gr)) == NULL) - return (-1); + } + + /* adding a group */ + if (sgr == NULL) + sgr = gr; eof = 0; len = 0; |
