diff options
author | 2014-11-19 01:07:58 +0000 | |
---|---|---|
committer | 2014-11-19 01:07:58 +0000 | |
commit | 1191611aa1bf45ab42f08651b0234155c0e6605b (patch) | |
tree | 9a4c079f60ef6f050589283cb57661673c01fbc0 /libutil | |
parent | 094b0b77ca298c10cc5780f3b66e11010543325d (diff) | |
parent | 2beb8074e6d6662d92adb15321b33c20310152bd (diff) | |
download | pw-darwin-1191611aa1bf45ab42f08651b0234155c0e6605b.tar.gz pw-darwin-1191611aa1bf45ab42f08651b0234155c0e6605b.tar.zst pw-darwin-1191611aa1bf45ab42f08651b0234155c0e6605b.zip |
Merge from head@274682
Diffstat (limited to 'libutil')
-rw-r--r-- | libutil/gr_util.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libutil/gr_util.c b/libutil/gr_util.c index 6f74507..465efd9 100644 --- a/libutil/gr_util.c +++ b/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; |