Blob Blame Raw
From 1c6e7a4ab586ebb221002c8881e0b44560d1b09d Mon Sep 17 00:00:00 2001
From: Daniel Mack <daniel@zonque.org>
Date: Tue, 28 Jul 2015 13:58:40 +0200
Subject: [PATCH 23/47] udev: check more builtins[] pointers before
 dereferencing

Fix some more locations where pointers from builtins[] are dereferenced
before checking. Related to 8cacf69b1.
---
 src/udev/udev-builtin.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index 88d1acf..3ebefa8 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -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);
-- 
2.5.0