From 77eacc73737116b101278ac7984c1a85adb55950 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 28 Oct 2014 14:54:04 +0000 Subject: 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 --- pw/pw_group.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pw/pw_group.c') 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"); -- cgit v1.2.3