[gnome-settings-daemon/benzea/add-backlight-helper-error: 9/9] power: Add missing error checking to realpath call
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/benzea/add-backlight-helper-error: 9/9] power: Add missing error checking to realpath call
- Date: Sat, 29 Feb 2020 20:55:44 +0000 (UTC)
commit 25a879cca8e79a431037fb63c391ac8469ad1190
Author: Benjamin Berg <bberg redhat com>
Date: Wed Feb 19 13:33:11 2020 +0100
power: Add missing error checking to realpath call
The realpath call happens on a user given path which may be invalid. If
an error happens, print this rather than crashing later on.
See #496 for this happening to a user
plugins/power/gsd-backlight-helper.c | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/plugins/power/gsd-backlight-helper.c b/plugins/power/gsd-backlight-helper.c
index 852446ca..c370c791 100644
--- a/plugins/power/gsd-backlight-helper.c
+++ b/plugins/power/gsd-backlight-helper.c
@@ -86,6 +86,11 @@ main (int argc, char *argv[])
}
device = realpath (argv[1], NULL);
+ if (device == NULL) {
+ fprintf (stderr, "Error: Could not canonicalize given path (%d: %s)\n", errno, strerror
(errno));
+ result = GSD_BACKLIGHT_HELPER_EXIT_CODE_FAILED;
+ goto done;
+ }
dp = opendir ("/sys/class/backlight");
if (dp == NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]