summaryrefslogtreecommitdiffstats
path: root/pw/pw_group.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2014-10-28 14:54:04 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2014-10-28 14:54:04 +0000
commit85717372d65dd2fe05ea2b086c24f03cbe7d1206 (patch)
tree83c0bdb85e1364b4f9ac99d390b9abeec4775489 /pw/pw_group.c
parentc61c6f66352171814a5d114527357d837df5cad9 (diff)
downloadpw-darwin-85717372d65dd2fe05ea2b086c24f03cbe7d1206.tar.gz
pw-darwin-85717372d65dd2fe05ea2b086c24f03cbe7d1206.tar.zst
pw-darwin-85717372d65dd2fe05ea2b086c24f03cbe7d1206.zip
Do not delete the group wheel when bad argument is passed to pw groupdel -g
Check that the -g argument is actually a number, if not report an error. This argument is converted without checking with atoi(3) later so without this check it converts any alpha entries into 0 meaning it deletes the group wheel Add a regression test about it PR: 90114 Reported by: bkoenig@cs.tu-berlin.de MFC after: 1 week
Diffstat (limited to 'pw/pw_group.c')
-rw-r--r--pw/pw_group.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/pw/pw_group.c b/pw/pw_group.c
index 4ed6ea9..b20ce88 100644
--- a/pw/pw_group.c
+++ b/pw/pw_group.c
@@ -67,6 +67,11 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
NULL
};
+ if (a_gid != NULL) {
+ if (strspn(a_gid->val, "0123456789") != strlen(a_gid->val))
+ errx(EX_USAGE, "-g expects a number");
+ }
+
if (mode == M_LOCK || mode == M_UNLOCK)
errx(EX_USAGE, "'lock' command is not available for groups");