From: Yu Watanabe Date: Wed, 15 Jan 2025 14:43:37 +0000 (+0900) Subject: udev-rules: ignore whole command result if it is too long and does not contain newline X-Git-Tag: v258-rc1~1568^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=68b1e1b61ab333bb4dee4a43373bad54080e755f;p=thirdparty%2Fsystemd.git udev-rules: ignore whole command result if it is too long and does not contain newline --- diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 0ba7f6beb8d..3ea1a2346b0 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -2380,15 +2380,18 @@ static int udev_rule_apply_token_to_event( } if (truncated) { - bool found = false; + log_event_debug(event, token, "Result of \"%s\" is too long and truncated, ignoring the last line of the result.", buf); /* Drop the last line. */ + bool found = false; for (char *p = PTR_SUB1(buf + strlen(buf), buf); p; p = PTR_SUB1(p, buf)) if (strchr(NEWLINE, *p)) { *p = '\0'; found = true; - } else if (found) break; + } + if (!found) + buf[0] = '\0'; } r = strv_split_newlines_full(&lines, result, EXTRACT_RETAIN_ESCAPE);