fb7efb
From 7af9382c2dcadebd7633ed858bd6baf211f3d9c0 Mon Sep 17 00:00:00 2001
fb7efb
From: Lidong Zhong <lzhong@suse.com>
fb7efb
Date: Tue, 28 Jul 2015 19:07:05 +0800
fb7efb
Subject: [PATCH 22/47] udev: avoid coredump when initializing udev builtins
fb7efb
fb7efb
If one of the macros(HAVE_BLKID/HAVE_KMOD/HAVE_ACL) is not
fb7efb
defined, there will be a coredump
fb7efb
---
fb7efb
 src/udev/udev-builtin.c | 11 ++++++-----
fb7efb
 1 file changed, 6 insertions(+), 5 deletions(-)
fb7efb
fb7efb
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
fb7efb
index fabc653..88d1acf 100644
fb7efb
--- a/src/udev/udev-builtin.c
fb7efb
+++ b/src/udev/udev-builtin.c
fb7efb
@@ -52,7 +52,7 @@ void udev_builtin_init(struct udev *udev) {
fb7efb
                 return;
fb7efb
 
fb7efb
         for (i = 0; i < ELEMENTSOF(builtins); i++)
fb7efb
-                if (builtins[i]->init)
fb7efb
+                if (builtins[i] && builtins[i]->init)
fb7efb
                         builtins[i]->init(udev);
fb7efb
 
fb7efb
         initialized = true;
fb7efb
@@ -65,7 +65,7 @@ void udev_builtin_exit(struct udev *udev) {
fb7efb
                 return;
fb7efb
 
fb7efb
         for (i = 0; i < ELEMENTSOF(builtins); i++)
fb7efb
-                if (builtins[i]->exit)
fb7efb
+                if (builtins[i] && builtins[i]->exit)
fb7efb
                         builtins[i]->exit(udev);
fb7efb
 
fb7efb
         initialized = false;
fb7efb
@@ -75,7 +75,7 @@ bool udev_builtin_validate(struct udev *udev) {
fb7efb
         unsigned int i;
fb7efb
 
fb7efb
         for (i = 0; i < ELEMENTSOF(builtins); i++)
fb7efb
-                if (builtins[i]->validate && builtins[i]->validate(udev))
fb7efb
+                if (builtins[i] && builtins[i]->validate && builtins[i]->validate(udev))
fb7efb
                         return true;
fb7efb
         return false;
fb7efb
 }
fb7efb
@@ -84,7 +84,8 @@ void udev_builtin_list(struct udev *udev) {
fb7efb
         unsigned int i;
fb7efb
 
fb7efb
         for (i = 0; i < ELEMENTSOF(builtins); i++)
fb7efb
-                fprintf(stderr, "  %-14s  %s\n", builtins[i]->name, builtins[i]->help);
fb7efb
+                if (builtins[i])
fb7efb
+                        fprintf(stderr, "  %-14s  %s\n", builtins[i]->name, builtins[i]->help);
fb7efb
 }
fb7efb
 
fb7efb
 const char *udev_builtin_name(enum udev_builtin_cmd cmd) {
fb7efb
@@ -105,7 +106,7 @@ enum udev_builtin_cmd udev_builtin_lookup(const char *command) {
fb7efb
         if (pos)
fb7efb
                 pos[0] = '\0';
fb7efb
         for (i = 0; i < ELEMENTSOF(builtins); i++)
fb7efb
-                if (streq(builtins[i]->name, name))
fb7efb
+                if (builtins[i] && streq(builtins[i]->name, name))
fb7efb
                         return i;
fb7efb
         return UDEV_BUILTIN_MAX;
fb7efb
 }
fb7efb
-- 
fb7efb
2.5.0
fb7efb