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

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>
1 file changed