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.
This commit is contained in:
Ali Raza 2026-03-07 03:43:59 +05:00
parent 2ad3e071c3
commit 0be2a8f9c8

View File

@ -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. */