cpio: testsuite for http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466771
[oweals/busybox.git] / modutils / modprobe.c
index db946bb2e25ab0e74cd7fb6e726dea897c28e028..1a4f5d4d42c60f404a4a316ef46919cf1c9ff373 100644 (file)
@@ -232,10 +232,10 @@ static char *parse_command_string(char *src, char **dst)
 #endif /* ENABLE_FEATURE_MODPROBE_MULTIPLE_OPTIONS */
 
 static int is_conf_command(char *buffer, const char *command)
-{ 
+{
        int len = strlen(command);
        return ((strstr(buffer, command) == buffer) &&
-                       isspace(buffer[len])); 
+                       isspace(buffer[len]));
 }
 
 /*
@@ -325,7 +325,7 @@ static void include_conf(struct dep_t **first, struct dep_t **current, char *buf
                                include_conf(first, current, buffer, buflen, fdi);
                                close(fdi);
                        }
-               } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST && 
+               } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST &&
                                (is_conf_command(buffer, "blacklist"))) {
                        char *mod;
                        struct dep_t *dt;
@@ -443,10 +443,8 @@ static struct dep_t *build_dep(void)
                        /* It's a dep description continuation */
                        p = line_buffer;
 
-               p = skip_whitespace(p);
-
                /* p points to the first dependable module; if NULL, no dependable module */
-               if (p && *p) {
+               if (p && (p = skip_whitespace(p))[0] != '\0') {
                        char *end = &line_buffer[l-1];
                        const char *deps;
                        char *dep;
@@ -484,10 +482,8 @@ static struct dep_t *build_dep(void)
                                dep = xstrndup(deps, next - deps - ext + 1);
 
                                /* Add the new dependable module name */
-                               current->m_depcnt++;
-                               current->m_deparr = xrealloc(current->m_deparr,
-                                               sizeof(char *) * current->m_depcnt);
-                               current->m_deparr[current->m_depcnt - 1] = dep;
+                               current->m_deparr = xrealloc_vector(current->m_deparr, 2, current->m_depcnt);
+                               current->m_deparr[current->m_depcnt++] = dep;
 
                                p = next + 2;
                        } while (next < end);