chiark / gitweb /
networkd: fix kernel rtnl receive buffer overrun error
[elogind.git] / src / shared / conf-parser.h
index 94185152cdecda1eb519925673d0c42d435c7cd0..69d32711b7fbfcd94a1df1462571388b44458901 100644 (file)
@@ -92,6 +92,14 @@ int config_parse(const char *unit,
                  bool warn,
                  void *userdata);
 
+int config_parse_many(const char *conf_file,      /* possibly NULL */
+                      const char *conf_file_dirs, /* nulstr */
+                      const char *sections,       /* nulstr */
+                      ConfigItemLookup lookup,
+                      const void *table,
+                      bool relaxed,
+                      void *userdata);
+
 /* Generic parsers */
 int config_parse_int(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_unsigned(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
@@ -169,7 +177,8 @@ int log_syntax_internal(const char *unit, int level,
                      void *data,                                               \
                      void *userdata) {                                         \
                                                                                \
-                type **enums = data, *xs, x, *ys;                              \
+                type **enums = data, x, *ys;                                   \
+                _cleanup_free_ type *xs = NULL;                                \
                 const char *word, *state;                                      \
                 size_t l, i = 0;                                               \
                                                                                \
@@ -186,6 +195,7 @@ int log_syntax_internal(const char *unit, int level,
                                                                                \
                 FOREACH_WORD(word, l, rvalue, state) {                         \
                         _cleanup_free_ char *en = NULL;                        \
+                        type *new_xs;                                          \
                                                                                \
                         en = strndup(word, l);                                 \
                         if (!en)                                               \
@@ -211,8 +221,10 @@ int log_syntax_internal(const char *unit, int level,
                                 continue;                                      \
                                                                                \
                         *(xs + i) = x;                                         \
-                        xs = realloc(xs, (++i + 1) * sizeof(type));            \
-                        if (!xs)                                               \
+                        new_xs = realloc(xs, (++i + 1) * sizeof(type));        \
+                        if (new_xs)                                            \
+                                xs = new_xs;                                   \
+                        else                                                   \
                                 return -ENOMEM;                                \
                                                                                \
                         *(xs + i) = invalid;                                   \
@@ -220,5 +232,7 @@ int log_syntax_internal(const char *unit, int level,
                                                                                \
                 free(*enums);                                                  \
                 *enums = xs;                                                   \
+                xs = NULL;                                                     \
+                                                                               \
                 return 0;                                                      \
         }