Skip to content

test/ringbuf-read: bound strcpy of argv[1] into fname#1582

Merged
axboe merged 1 commit into
axboe:masterfrom
rootvector2:ringbuf-read-fname-bound
May 28, 2026
Merged

test/ringbuf-read: bound strcpy of argv[1] into fname#1582
axboe merged 1 commit into
axboe:masterfrom
rootvector2:ringbuf-read-fname-bound

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

Stack overflow in test/ringbuf-read.c main() — argv[1] is copied into the
80-byte fname[] with an unbounded strcpy. Running the test with a long
path argument trips a stack-buffer-overflow under ASan.

Replace the strcpy with snprintf() bounded by sizeof(fname). Full
context is in the commit message.

main() copies argv[1] into the 80-byte fname[] stack buffer with an
unbounded strcpy. Passing a path longer than 79 bytes overflows the
buffer and clobbers the surrounding frame, e.g.

  $ ./ringbuf-read $(python3 -c 'print("A"*256)')

triggers a stack-buffer-overflow under -fsanitize=address. Replace
the strcpy with snprintf() bounded by sizeof(fname).

Signed-off-by: rootvector2 <dxbnaveed.k@gmail.com>
@axboe axboe merged commit a33a770 into axboe:master May 28, 2026
20 checks passed
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