eta: fix previous line length calculation
We work out how many stale characters we haven't yet overprinted from
the previous run by comparing the number of characters that snprintf
added to the buffer in both cases. Unfortunately this doesn't account
for earlier characters that may (or may not) have already been in the
output buffer before snprintf was called...
Change the code to just use the current and previous output buffer
position to calculate the remainder of the line to be cleared.
When fio is compiled under clang with
./configure --extra-cflags="-fsanitize=address -fno-builtin" \
--disable-optimizations
a buffer overrun is demonstrated by the following script
rw[0]='read'; rw[1]='write'; \
for i in {1..4096}; do \
echo -e "[job$i]\nrw=${rw[$((i % 2))]}\n" \
"ramp_time=$(((4096 - i) / 2049 * 10))\n" \
"runtime=15"; \
done | \
./fio --group_reporting --ioengine=null --size=1g --time_based \
--bs=512 --thread --rate_iops=2 -
Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>