util: fix possible return of unsanitized input in str_sanitize

Fixes: 71a2c5cae2 ("util: sanitize control characters in str_sanitize()")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1493>
This commit is contained in:
Josiah Vehrs 2026-06-10 18:17:53 -07:00
parent b577a77333
commit a487280e09

View file

@ -572,7 +572,7 @@ str_sanitize(const char *str)
}
}
if (!needs_sanitization)
return strdup(str);
return strndup(str, slen);
char *sanitized = zalloc(2 * slen + 1);
const char *src = str;