coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Fix a bug in split where chunking would be skipped when the chunk size

Open resistor opened this issue 3 years ago • 0 comments

happened to be an exact divisor of the buffer size used to read the input stream.

The issue here was that file was being split byte-wise in chunks of 1G. The input stream was being read in chunks of 8KB, which evenly divides the chunk size. Because the check to allocate the next output chunk was done at the bottom of the loop previously, it would never occur because the current input chunk was fully consumed at that point. By moving the check to the top of the loop (but still late enough that we know we have bytes to write) we resolve this issue.

This scenario is unfortunately hard to write a test for, since we don't explicitly control the input chunk size.

Fixes https://github.com/uutils/coreutils/issues/3790

resistor avatar Aug 10 '22 05:08 resistor