fbd-ledctrl: Add null pointer check for groups

The set_perms function does not check if getgrnam returns a null
pointer.

This causes the fbd-ledctrl to crash when a non-existent group is
passed.
This commit is contained in:
Dang Huynh
2024-11-16 21:35:40 +01:00
committed by Guido Günther
parent 9e6c1aba16
commit f2e59a4ee0
+4
View File
@@ -124,6 +124,10 @@ set_perms (const char *sysfs_path, const char *trigger, const char *gname)
gboolean success = TRUE;
group = getgrnam (gname);
if (!group) {
fprintf (stderr, "Failed to get group %s\n", gname);
return FALSE;
}
if (!set_sysfs_attr_perm (sysfs_path, LED_BRIGHTNESS_ATTR, group->gr_gid))
return FALSE;