win: fix path size calculation

_snwprintf_s takes its length argument in characters, not bytes.

Does not appear to be a security issue because the paths are not under
an attacker's control unless the system has been compromised beyond
salvation: requires a combination of being able to set the name of the
executable and/or changing %LOCALAPPDATA% or a registry key.

Refs: https://github.com/libuv/libuv/security/advisories/GHSA-jjrx-vr7q-7732
This commit is contained in:
Ben Noordhuis 2025-09-02 22:42:18 +02:00
parent c6330d9655
commit 9940f1ea64

View File

@ -1220,7 +1220,7 @@ static int uv__kill(HANDLE process_handle, int signum) {
NULL,
&localappdata);
_snwprintf_s(dump_folder,
sizeof(dump_folder),
ARRAY_SIZE(dump_folder),
_TRUNCATE,
L"%ls\\CrashDumps",
localappdata);
@ -1233,7 +1233,7 @@ static int uv__kill(HANDLE process_handle, int signum) {
/* Construct dump filename from process name and PID. */
_snwprintf_s(dump_name,
sizeof(dump_name),
ARRAY_SIZE(dump_name),
_TRUNCATE,
L"%ls\\%ls.%d.dmp",
dump_folder,