]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: check more builtins[] pointers before dereferencing
authorDaniel Mack <daniel@zonque.org>
Tue, 28 Jul 2015 11:58:40 +0000 (13:58 +0200)
committerDaniel Mack <daniel@zonque.org>
Tue, 28 Jul 2015 11:58:40 +0000 (13:58 +0200)
Fix some more locations where pointers from builtins[] are dereferenced
before checking. Related to 8cacf69b1.

src/udev/udev-builtin.c

index 88d1acf168587248f3c05d9143e3ccb30db630a1..3ebefa84e27eb88634bae638c89411cf25c0b8e1 100644 (file)
@@ -89,10 +89,16 @@ void udev_builtin_list(struct udev *udev) {
 }
 
 const char *udev_builtin_name(enum udev_builtin_cmd cmd) {
+        if (!builtins[cmd])
+                return NULL;
+
         return builtins[cmd]->name;
 }
 
 bool udev_builtin_run_once(enum udev_builtin_cmd cmd) {
+        if (!builtins[cmd])
+                return -EOPNOTSUPP;
+
         return builtins[cmd]->run_once;
 }
 
@@ -116,6 +122,9 @@ int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const c
         int argc;
         char *argv[128];
 
+        if (!builtins[cmd])
+                return -EOPNOTSUPP;
+
         /* we need '0' here to reset the internal state */
         optind = 0;
         strscpy(arg, sizeof(arg), command);