pw: fix uninitialized name pointer in pw_group_del
The 'name' variable could be left uninitialized if neither the positional argument nor -n is supplied, leading to undefined behavior when passed to getgroup().
This commit is contained in:
@@ -367,7 +367,7 @@ pw_group_del(int argc, char **argv, char *arg1)
|
||||
{
|
||||
struct userconf *cnf = NULL;
|
||||
struct group *grp = NULL;
|
||||
char *name;
|
||||
char *name = NULL;
|
||||
const char *cfg = NULL;
|
||||
intmax_t id = -1;
|
||||
int ch, rc;
|
||||
|
||||
@@ -18,6 +18,20 @@ group_do_not_delete_wheel_if_group_unknown_body() {
|
||||
}
|
||||
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case group_do_not_delete_wheel_if_group_unknown
|
||||
atf_test_case group_delete_by_gid cleanup
|
||||
group_delete_by_gid_head() {
|
||||
atf_set "descr" "Test deleting a group by gid without providing a name"
|
||||
}
|
||||
group_delete_by_gid_body() {
|
||||
populate_etc_skel
|
||||
${PW} groupadd testgroup -g 1000 || atf_fail "Creating test group"
|
||||
atf_check -s exit:0 -o inline:"testgroup:*:1000:\n" \
|
||||
-x ${PW} groupshow 1000
|
||||
${PW} groupdel -g 1000 || atf_fail "Deleting group by gid"
|
||||
}
|
||||
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case group_do_not_delete_wheel_if_group_unknown
|
||||
atf_add_test_case group_delete_by_gid
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user