summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pw/pw_group.c
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2014-10-28 14:54:04 +0000
committerbapt <bapt@FreeBSD.org>2014-10-28 14:54:04 +0000
commita06e911fb2a286f878cb79baa795e39f92145199 (patch)
treea2f0ffe4ed0f1a3ea9445e29fda8f37cb104a2eb /usr.sbin/pw/pw_group.c
parent95f601fb4fb00e90246cb9450b07534d6b874654 (diff)
downloadFreeBSD-src-a06e911fb2a286f878cb79baa795e39f92145199.zip
FreeBSD-src-a06e911fb2a286f878cb79baa795e39f92145199.tar.gz
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 'usr.sbin/pw/pw_group.c')
-rw-r--r--usr.sbin/pw/pw_group.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c
index 4ed6ea9..b20ce88 100644
--- a/usr.sbin/pw/pw_group.c
+++ b/usr.sbin/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");
OpenPOWER on IntegriCloud