From cb49f3148007931a033045222fdef2ff89ffe4c8 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 1 Mar 2024 19:15:40 +0000 Subject: [PATCH] deps: cherry-pick libuv/libuv@d09441c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: fs: fix WTF-8 decoding issue (#4092) We forgot to mask off the high bits from the first byte, so we ended up always failing the subsequent range check. Refs: https://github.com/libuv/libuv/pull/2970 Fixes: https://github.com/nodejs/node/issues/48673 PR-URL: https://github.com/nodejs/node/pull/51976 Refs: https://github.com/nodejs/node/issues/48673 Reviewed-By: Rafael Gonzaga Reviewed-By: Luigi Pinca Reviewed-By: Marco Ippolito Reviewed-By: Santiago Gimeno Reviewed-By: Ulises Gascón --- deps/uv/src/win/fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index fc209c54f470ed..4fc13b04bdae5b 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -176,9 +176,11 @@ static int32_t fs__decode_wtf8_char(const char** input) { if ((b4 & 0xC0) != 0x80) return -1; /* invalid: not a continuation byte */ code_point = (code_point << 6) | (b4 & 0x3F); - if (b1 <= 0xF4) + if (b1 <= 0xF4) { + code_point &= 0x1FFFFF; if (code_point <= 0x10FFFF) return code_point; /* four-byte character */ + } /* code point too large */ return -1;