standard output is fully buffered, e.g., when redirected to a file.
[bug introduced in coreutils-9.10]
+ 'unexpand -t' no longer overflows a heap buffer, for tab values > SIZE_MAX/16.
+ [bug introduced in coreutils-9.11]
+
'uniq -w' no longer overruns the read buffer in multibyte locales.
[bug introduced in coreutils-9.5]
/* The worst case is a non-blank character, then one blank, then a
tab stop, then MAX_COLUMN_WIDTH - 1 blanks, then a non-blank; so
allocate MAX_COLUMN_WIDTH bytes to store the blanks. */
- pending_blank = ximalloc (max_column_width * sizeof (char) * MB_LEN_MAX);
+ pending_blank = xinmalloc (max_column_width, MB_CUR_MAX);
while (true)
{
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ unexpand printf
+getlimits_
test "$LOCALE_FR_UTF8" != none || skip_ "French UTF-8 locale not available"
export LC_ALL="$LOCALE_FR_UTF8"
unexpand -a ./in ./in > out || fail=1
compare exp out > /dev/null 2>&1 || fail=1
+# Ensure overflow is handed gracefully
+# coreutils v9.11 induced a buffer overflow with mb_mul=4 (or 16).
+for mb_mul in 4 6; do
+ printf ' \n' | unexpand -t $(expr $SIZE_MAX / $mb_mul + 1) 2>err; ret=$?
+ test "$ret" = 1 || test "$ret" = 0 || { cat err; fail=1; }
+done
+
Exit $fail