summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2002-05-17 04:07:50 +0000
committermillert <millert@openbsd.org>2002-05-17 04:07:50 +0000
commit1cead3af0252b91ae1ef3e46bd92265875401d06 (patch)
tree41f8cb4ce2e074839dd1817c5827175842826120
parentisp* here too (diff)
downloadwireguard-openbsd-1cead3af0252b91ae1ef3e46bd92265875401d06.tar.xz
wireguard-openbsd-1cead3af0252b91ae1ef3e46bd92265875401d06.zip
When modifying a group w/ no members with groupmod(8) the trailing
newline was not added. Reported by Rob Sessink, different fix by me.
-rw-r--r--usr.sbin/user/user.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c
index 47c845ed58b..47cddacbaea 100644
--- a/usr.sbin/user/user.c
+++ b/usr.sbin/user/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.33 2002/04/04 18:39:32 millert Exp $ */
+/* $OpenBSD: user.c,v 1.34 2002/05/17 04:07:50 millert Exp $ */
/* $NetBSD: user.c,v 1.45 2001/08/17 08:29:00 joda Exp $ */
/*
@@ -1738,12 +1738,14 @@ groupmod(int argc, char **argv)
if (cc >= sizeof(buf))
err(EXIT_FAILURE, "group `%s' entry too long",
grp->gr_name);
- if (cpp[1] == NULL)
- buf[cc - 1] = '\n';
- else
+ if (cpp[1] != NULL) {
buf[cc - 1] = ',';
- buf[cc] = '\0';
+ buf[cc] = '\0';
+ }
}
+ cc = strlcat(buf, "\n", sizeof(buf));
+ if (cc >= sizeof(buf))
+ err(EXIT_FAILURE, "group `%s' entry too long", grp->gr_name);
if (!modify_gid(*argv, buf))
err(EXIT_FAILURE, "can't change %s file", _PATH_GROUP);