Skip to content

fix(process): out-of-bounds write when reading child process output#80

Merged
cegonse merged 1 commit into
cegonse:masterfrom
jamofer:fix/process-oob-read
Jun 9, 2026
Merged

fix(process): out-of-bounds write when reading child process output#80
cegonse merged 1 commit into
cegonse:masterfrom
jamofer:fix/process-oob-read

Conversation

@jamofer

@jamofer jamofer commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

read() can return up to buffer.size() (4096) bytes, so buffer[read_bytes + 1] = '\0' wrote past the end of the 4096-byte stack array — a stack buffer overflow when a child filled the buffer. Under ASan this surfaces as stack-buffer-overflow; without it, undefined behavior.

Fix: append exactly read_bytes bytes to the output string and drop the manual null terminator. Also stop the read loop on error (read() returning -1) instead of looping forever.

@jamofer jamofer changed the title Fix out-of-bounds write when reading child process output fix(process): out-of-bounds write when reading child process output Jun 8, 2026
@cegonse

cegonse commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Thanks a lot @jamofer ! Merged!

@cegonse cegonse merged commit 79d8475 into cegonse:master Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants