From 340027e317df176bd135f1ad32a15285ffa6ad86 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 4 Jul 2025 12:09:54 +0100 Subject: [PATCH] steam_helper: Null terminate escape_path_unix_to_dos. WideCharToMultiByte does not null terminate if a null character is not included in the input length. CW-Bug-Id: #24534 --- steam_helper/steam.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/steam_helper/steam.c b/steam_helper/steam.c index fc13d697..3965c78f 100644 --- a/steam_helper/steam.c +++ b/steam_helper/steam.c @@ -115,7 +115,11 @@ static char *escape_path_unix_to_dos( const char *path ) for (src = dos, dst = tmp; *src; src++, dst++) if ((*dst = *src) == '\\') *++dst = '\\'; if (!(len = WideCharToMultiByte( CP_UTF8, 0, tmp, (dst - tmp), NULL, 0, NULL, NULL ))) goto done; - if ((escaped = malloc( len ))) WideCharToMultiByte( CP_UTF8, 0, tmp, (dst - tmp), escaped, len, NULL, NULL ); + if ((escaped = malloc( len + 1 ))) + { + WideCharToMultiByte( CP_UTF8, 0, tmp, (dst - tmp), escaped, len, NULL, NULL ); + escaped[len] = '\0'; + } done: HeapFree( GetProcessHeap(), 0, dos );