]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-ctrl: refuse ENV control message with invalid environment assignment 35736/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 21 Dec 2024 21:34:33 +0000 (06:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 4 Jan 2025 12:54:40 +0000 (21:54 +0900)
Previously, udevd accepts an arbitrary pair of key and value.
Let's make the environment variable assignment more strict for safety.

Note, we already refuse environment variables with the same way in
net/link-config.c.

src/udev/udev-manager.c

index b7bce977d1d0819ed99e8c0e9111a9e1e5af93ba..1768da5a3884f9973e48a539cf54adee280e53e6 100644 (file)
@@ -871,19 +871,15 @@ static int on_ctrl_msg(UdevCtrl *uctrl, UdevCtrlMessageType type, const UdevCtrl
                 log_debug("Received udev control message (RELOAD)");
                 manager_reload(manager, /* force = */ true);
                 break;
-        case UDEV_CTRL_SET_ENV: {
-                const char *eq;
-
-                eq = strchr(value->buf, '=');
-                if (!eq) {
-                        log_error("Invalid key format '%s'", value->buf);
-                        return 1;
+        case UDEV_CTRL_SET_ENV:
+                if (!udev_property_assignment_is_valid(value->buf)) {
+                        log_debug("Received invalid udev control message(SET_ENV, %s), ignoring.", value->buf);
+                        break;
                 }
 
                 log_debug("Received udev control message(SET_ENV, %s)", value->buf);
                 manager_set_environment(manager, STRV_MAKE(value->buf));
                 break;
-        }
         case UDEV_CTRL_SET_CHILDREN_MAX:
                 if (value->intval < 0) {
                         log_debug("Received invalid udev control message (SET_MAX_CHILDREN, %i), ignoring.", value->intval);