]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: refuse invalid ifname earlier
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 23 Jun 2021 07:17:21 +0000 (16:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 23 Jun 2021 07:32:42 +0000 (16:32 +0900)
src/udev/udev-event.c

index 8a01e2512e35be6f425ab5591efef535f2a02110..b28089be71c8935e499ef5d65ff068369bbc3613 100644 (file)
@@ -17,6 +17,7 @@
 #include "fd-util.h"
 #include "fs-util.h"
 #include "format-util.h"
+#include "netif-naming-scheme.h"
 #include "netlink-util.h"
 #include "parse-util.h"
 #include "path-util.h"
@@ -848,6 +849,12 @@ static int rename_netif(UdevEvent *event) {
         if (r < 0)
                 return log_device_error_errno(dev, r, "Failed to get ifindex: %m");
 
+        if (naming_scheme_has(NAMING_REPLACE_STRICTLY) &&
+            !ifname_valid(event->name)) {
+                log_device_warning(dev, "Invalid network interface name, ignoring: %s", event->name);
+                return 0;
+        }
+
         /* Set ID_RENAMING boolean property here, and drop it in the corresponding move uevent later. */
         r = device_add_property(dev, "ID_RENAMING", "1");
         if (r < 0)