From: Yu Watanabe Date: Sat, 21 Dec 2024 21:34:33 +0000 (+0900) Subject: udev-ctrl: refuse ENV control message with invalid environment assignment X-Git-Tag: v258-rc1~1715^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F35736%2Fhead;p=thirdparty%2Fsystemd.git udev-ctrl: refuse ENV control message with invalid environment assignment 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. --- diff --git a/src/udev/udev-manager.c b/src/udev/udev-manager.c index b7bce977d1d..1768da5a388 100644 --- a/src/udev/udev-manager.c +++ b/src/udev/udev-manager.c @@ -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);