mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
Utilities: Fix null deref in groupdel
when given a nonexistent group
Found By PVS-Studio
This commit is contained in:
parent
fdfc0d1bac
commit
7b2506c054
1 changed files with 2 additions and 3 deletions
|
@ -30,7 +30,6 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* groupname = nullptr;
|
char const* groupname = nullptr;
|
||||||
gid_t gid = 0;
|
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_positional_argument(groupname, "Group name", "group");
|
args_parser.add_positional_argument(groupname, "Group name", "group");
|
||||||
|
@ -38,14 +37,14 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
setgrent();
|
setgrent();
|
||||||
auto* g = getgrnam(groupname);
|
auto* g = getgrnam(groupname);
|
||||||
gid = g->gr_gid;
|
|
||||||
endgrent();
|
|
||||||
|
|
||||||
// Check if the group exists
|
// Check if the group exists
|
||||||
if (!g) {
|
if (!g) {
|
||||||
warnln("group {} does not exist", groupname);
|
warnln("group {} does not exist", groupname);
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
auto gid = g->gr_gid;
|
||||||
|
endgrent();
|
||||||
|
|
||||||
// Search if the group is the primary group of an user
|
// Search if the group is the primary group of an user
|
||||||
setpwent();
|
setpwent();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue