chiark / gitweb /
Reject invalid quoted strings
[elogind.git] / src / udev / net / link-config.c
index fe916a4326755e7fc0be49d2c89d77db6e831533..946715ce5a106911819982898beab5329b813a52 100644 (file)
@@ -153,11 +153,6 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
         assert(ctx);
         assert(filename);
 
-        if (null_or_empty_path(filename)) {
-                log_debug("skipping empty file: %s", filename);
-                return 0;
-        }
-
         file = fopen(filename, "re");
         if (!file) {
                 if (errno == ENOENT)
@@ -166,6 +161,11 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
                         return -errno;
         }
 
+        if (null_or_empty_fd(fileno(file))) {
+                log_debug("Skipping empty file: %s", filename);
+                return 0;
+        }
+
         link = new0(link_config, 1);
         if (!link)
                 return log_oom();
@@ -177,11 +177,10 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
         r = config_parse(NULL, filename, file,
                          "Match\0Link\0Ethernet\0",
                          config_item_perf_lookup, link_config_gperf_lookup,
-                         false, false, link);
-        if (r < 0) {
-                log_warning("Could not parse config file %s: %s", filename, strerror(-r));
+                         false, false, true, link);
+        if (r < 0)
                 return r;
-        else
+        else
                 log_debug("Parsed configuration file %s", filename);
 
         link->filename = strdup(filename);
@@ -194,7 +193,7 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
 
 static bool enable_name_policy(void) {
         _cleanup_free_ char *line = NULL;
-        char *w, *state;
+        const char *word, *state;
         int r;
         size_t l;
 
@@ -204,8 +203,8 @@ static bool enable_name_policy(void) {
         if (r <= 0)
                 return true;
 
-        FOREACH_WORD_QUOTED(w, l, line, state)
-                if (strneq(w, "net.ifnames=0", l))
+        FOREACH_WORD_QUOTED(word, l, line, state)
+                if (strneq(word, "net.ifnames=0", l))
                         return false;
 
         return true;