Hello, Thank you, Vivek, for confirming the overflow independently.
A gentle ping on the patch that opened this thread (17 October). It keeps the existing buffer handling in tape_buffered_peek as it is and caps each read at the room left in input_buffer, and it comes with a regression test, tests/ https://www.google.com/url?q=http://junk-short-read.at&source=gmail&ust=1795543414784000&sa=E, which extracts an archive with leading junk fed to cpio -i through a pipe in short pieces. "make check" passes with it in an ASan/UBSan build, and it still applies cleanly to current master (e5bb73f). I would be glad to rework anything you would like changed. Regards, Mar On Sat, Oct 17, 2026 02:39 PM, Mar <[email protected]> wrote: > Hello, > > tape_buffered_peek (src/util.c) appends up to io_block_size bytes at > in_buff + input_size, but makes room only once that point has reached > the end of input_buffer (2 * io_block_size bytes on copy-in). When the > archive comes from a pipe, reads can return short counts, so the append > point is not always block aligned: read_in_header's search for the > magic number then calls the peek again with the append point less than > a block from the end, and the full-block read there writes past the end > of the heap buffer. Regular files and tapes always return full blocks, > so they are not affected. > > The attached patch keeps the existing logic and limits each read to the > room left in the buffer, so full-block reads are unchanged. It adds a > test (tests/junk-short-read.at) that extracts an archive with leading > junk from a pipe fed in short pieces and checks the extracted file. > "make check" passes (19 tests) with an ASan/UBSan build. > > The patch is a git format-patch commit; if it looks right to you, I > would be grateful if it could go in with "git am" so that it keeps its > author, with any changes you want made in review. If you think the bug > warrants a CVE id, I can request one, or leave it to you. > > Regards, > Mar >
