summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2014-11-04 18:22:33 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2014-11-04 18:22:33 +0000
commitfb90d29ec2763027a93943b3f30250bd05afd62c (patch)
tree96a455d21208bb7513ef6e9f676483252d38afa3 /libutil
parenta67255c0571b3f564056b8dd161f54db9815c014 (diff)
parent8c4532e1189f5ef981aff455332acbfbb082cfa9 (diff)
downloadpw-darwin-fb90d29ec2763027a93943b3f30250bd05afd62c.tar.gz
pw-darwin-fb90d29ec2763027a93943b3f30250bd05afd62c.zip
Sync to HEAD@r274095.
Diffstat (limited to 'libutil')
-rw-r--r--libutil/gr_util.c17
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;