summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2015-07-28 13:58:40 +0200
committerDaniel Mack <daniel@zonque.org>2015-07-28 13:58:40 +0200
commitf89d10ae45107c675adbe02e2b1878ee0f5af5ee (patch)
tree4f95f858377f008d216e387ffb08fd89b73cad7d /src
parent87b46c575a14c133fbc408b56b0835f13a918b1d (diff)
udev: check more builtins[] pointers before dereferencing
Fix some more locations where pointers from builtins[] are dereferenced before checking. Related to 8cacf69b1.
Diffstat (limited to 'src')
-rw-r--r--src/udev/udev-builtin.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index 88d1acf168..3ebefa84e2 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);