[gnome-settings-daemon/benzea/add-backlight-helper-error] power: Add missing error checking to realpath call



commit 200b799f1dbffed9f5da120be61ca5481efb0297
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]