From 0be2a8f9c8ac80ce9eeac9ccf831d5ad1d4b6209 Mon Sep 17 00:00:00 2001 From: Ali Raza Date: Sat, 7 Mar 2026 03:43:59 +0500 Subject: [PATCH] win: replace hardcoded stdio count cap with overflow check The existing check rejected stdio_count > 255 with an arbitrary limit. Replace it with a SIZE_MAX-based overflow guard matching the approach used on Unix, so the allocation in CHILD_STDIO_SIZE(count) cannot wrap. --- src/win/process-stdio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/win/process-stdio.c b/src/win/process-stdio.c index 181db92ea..ea635c170 100644 --- a/src/win/process-stdio.c +++ b/src/win/process-stdio.c @@ -175,8 +175,9 @@ int uv__stdio_create(uv_loop_t* loop, count = options->stdio_count; - if (count < 0 || count > 255) { - /* Only support FDs 0-255 */ + if (count < 0 || + (size_t) count > (SIZE_MAX - sizeof(int)) / + (sizeof(unsigned char) + sizeof(uintptr_t))) { return ERROR_NOT_SUPPORTED; } else if (count < 3) { /* There should always be at least 3 stdio handles. */