diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-10-10 01:11:03 -0700 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-10-10 03:10:05 -0700 |
commit | 7b2506c054684815a11c635082923b688e138a18 (patch) | |
tree | fb26bfeabc61c5d57956b6cc10b6b470772078ef /Userland | |
parent | fdfc0d1bac8c390508366d14d80c149a23d59606 (diff) | |
download | serenity-7b2506c054684815a11c635082923b688e138a18.zip |
Utilities: Fix null deref in `groupdel` when given a nonexistent group
Found By PVS-Studio
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/groupdel.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Userland/Utilities/groupdel.cpp b/Userland/Utilities/groupdel.cpp index f4fff5d27d..f9cafd3e70 100644 --- a/Userland/Utilities/groupdel.cpp +++ b/Userland/Utilities/groupdel.cpp @@ -30,7 +30,6 @@ int main(int argc, char** argv) } char const* groupname = nullptr; - gid_t gid = 0; Core::ArgsParser args_parser; args_parser.add_positional_argument(groupname, "Group name", "group"); @@ -38,14 +37,14 @@ int main(int argc, char** argv) setgrent(); auto* g = getgrnam(groupname); - gid = g->gr_gid; - endgrent(); // Check if the group exists if (!g) { warnln("group {} does not exist", groupname); return 6; } + auto gid = g->gr_gid; + endgrent(); // Search if the group is the primary group of an user setpwent(); |