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:
committed by
Guido Günther
parent
9e6c1aba16
commit
f2e59a4ee0
@@ -124,6 +124,10 @@ set_perms (const char *sysfs_path, const char *trigger, const char *gname)
|
|||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
|
|
||||||
group = getgrnam (gname);
|
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))
|
if (!set_sysfs_attr_perm (sysfs_path, LED_BRIGHTNESS_ATTR, group->gr_gid))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
Reference in New Issue
Block a user