summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLidong Zhong <lzhong@suse.com>2015-07-28 19:07:05 +0800
committerLidong Zhong <lzhong@suse.com>2015-07-28 19:07:05 +0800
commit8cacf69b1b0dda4ad86c06dbba57f375865ccb6f (patch)
tree92f6cf33b09f4f5c00ffcab0e6f516a1fb91a3ea
parent7ee7b225bd2fc3e7a3980f5fb7b10dfc6e205578 (diff)
udev: avoid coredump when initializing udev builtins
If one of the macros(HAVE_BLKID/HAVE_KMOD/HAVE_ACL) is not defined, there will be a coredump
-rw-r--r--src/udev/udev-builtin.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index fabc653800..88d1acf168 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -52,7 +52,7 @@ void udev_builtin_init(struct udev *udev) {
return;
for (i = 0; i < ELEMENTSOF(builtins); i++)
- if (builtins[i]->init)
+ if (builtins[i] && builtins[i]->init)
builtins[i]->init(udev);
initialized = true;
@@ -65,7 +65,7 @@ void udev_builtin_exit(struct udev *udev) {
return;
for (i = 0; i < ELEMENTSOF(builtins); i++)
- if (builtins[i]->exit)
+ if (builtins[i] && builtins[i]->exit)
builtins[i]->exit(udev);
initialized = false;
@@ -75,7 +75,7 @@ bool udev_builtin_validate(struct udev *udev) {
unsigned int i;
for (i = 0; i < ELEMENTSOF(builtins); i++)
- if (builtins[i]->validate && builtins[i]->validate(udev))
+ if (builtins[i] && builtins[i]->validate && builtins[i]->validate(udev))
return true;
return false;
}
@@ -84,7 +84,8 @@ void udev_builtin_list(struct udev *udev) {
unsigned int i;
for (i = 0; i < ELEMENTSOF(builtins); i++)
- fprintf(stderr, " %-14s %s\n", builtins[i]->name, builtins[i]->help);
+ if (builtins[i])
+ fprintf(stderr, " %-14s %s\n", builtins[i]->name, builtins[i]->help);
}
const char *udev_builtin_name(enum udev_builtin_cmd cmd) {
@@ -105,7 +106,7 @@ enum udev_builtin_cmd udev_builtin_lookup(const char *command) {
if (pos)
pos[0] = '\0';
for (i = 0; i < ELEMENTSOF(builtins); i++)
- if (streq(builtins[i]->name, name))
+ if (builtins[i] && streq(builtins[i]->name, name))
return i;
return UDEV_BUILTIN_MAX;
}