* [to-be-updated] lib-string_helpers-use-full-destination-buffer-in-string_unescape.patch removed from -mm tree
@ 2026-10-07 2:00 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-07 2:00 UTC (permalink / raw)
To: mm-commits, kernel, kees, andy, jre, akpm
The quilt patch titled
Subject: lib/string_helpers: use full destination buffer in string_unescape()
has been removed from the -mm tree. Its filename was
lib-string_helpers-use-full-destination-buffer-in-string_unescape.patch
This patch was dropped because an updated version will be issued
------------------------------------------------------
From: Jonas Rebmann <jre@pengutronix.de>
Subject: lib/string_helpers: use full destination buffer in string_unescape()
Date: Wed, 16 Sep 2026 19:38:09 +0200
Although all of the available sequences expand to exactly one byte, the
current implementation decrements the remaining bytes in the destination
buffer twice, effectively shortening it by one byte per each unescaped
character.
The extra decrement is only needed in the one case where a single loop
iteration produces two output bytes: when the sequence turns out not to be
a valid escape sequence, the previously skipped backslash has to be
emitted before the character is copied verbatim.
Add a kunit regression-test that unescapes into a barely long enough 3
buffer.
Link: https://lore.kernel.org/20260916-string_unescape-v1-4-7f8bd986fa33@pengutronix.de
Fixes: 16c7fa05829e ("lib/string_helpers: introduce generic string_unescape")
Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Shevchenko <andy@kernel.org>
Cc: Kees Cook <kees@kernel.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
---
lib/string_helpers.c | 2 +-
lib/tests/string_helpers_kunit.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
--- a/lib/string_helpers.c~lib-string_helpers-use-full-destination-buffer-in-string_unescape
+++ a/lib/string_helpers.c
@@ -331,7 +331,6 @@ int string_unescape(char *src, char *dst
while (*src && --size) {
if (src[0] == '\\' && src[1] != '\0' && size > 1) {
src++;
- size--;
if (flags & UNESCAPE_SPACE &&
unescape_space(&src, &out))
@@ -350,6 +349,7 @@ int string_unescape(char *src, char *dst
continue;
*out++ = '\\';
+ size--;
}
*out++ = *src++;
}
--- a/lib/tests/string_helpers_kunit.c~lib-string_helpers-use-full-destination-buffer-in-string_unescape
+++ a/lib/tests/string_helpers_kunit.c
@@ -623,6 +623,9 @@ static void test_unescape(struct kunit *
test_string_unescape_one(test, "escape at end", UNESCAPE_HEX, "a\\qX", 3, "a\\", 2);
test_string_unescape_one(test, "backslash before escape", UNESCAPE_HEX, "\\\\x41B", 12, "\\\\x41B", 6);
test_string_unescape_one(test, "backslash escape", UNESCAPE_HEX | UNESCAPE_SPECIAL, "\\\\x41B", 16, "\\x41B", 5);
+
+ test_string_unescape_one(test, "short buffer", UNESCAPE_HEX, "\\x41\\x41B", 4, "AAB", 3);
+ test_string_unescape_one(test, "unrecognized escape at end", UNESCAPE_HEX, "B\\qX", 4, "B\\q", 3);
}
static void test_escape(struct kunit *test)
_
Patches currently in -mm which might be from jre@pengutronix.de are
lib-string_helpers-fix-counting-of-remaining-bytes-in-string_unescape.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-07 2:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 2:00 [to-be-updated] lib-string_helpers-use-full-destination-buffer-in-string_unescape.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.