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



commit 8d3ab5419e7ea7dfc08e2042f8d6a890524c1694
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..3991082e 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 cannonicalize 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]