'numfmt' no longer reads out-of-bounds memory with trailing blanks in input.
[bug introduced with numfmt in coreutils-8.21]
+ 'numfmt' no longer outputs invalid characters with multi-byte blanks in input.
+ [bug introduced in coreutils-9.5]
+
'rm -d DIR' no longer fails on Ceph snapshot directories.
Although these directories are nonempty, 'rmdir DIR' succeeds on them.
[bug introduced in coreutils-8.16]
errno = 0;
user_precision = strtol (fmt + i, &endptr, 10);
if (errno == ERANGE || user_precision < 0 || SIZE_MAX < user_precision
- || isblank (fmt[i]) || fmt[i] == '+')
+ || c_isblank (fmt[i]) || fmt[i] == '+')
{
/* Note we disallow negative user_precision to be
consistent with printf(1). POSIX states that
devmsg ("no valid suffix found\n");
}
- /* Skip white space - always. */
- char *p = text;
- while (*p && isblank (to_uchar (*p)))
- ++p;
+ /* Skip blanks - always. */
+ char *p = skip_str_matching (text, newline_or_blank, true);
/* setup auto-padding. */
if (auto_padding)
{
- padding_width = text < p || 1 < field ? strlen (text) : 0;
+ padding_width = text < p || 1 < field
+ ? mbswidth (text,
+ MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE)
+ : 0;
+ if (padding_width < 0)
+ padding_width = strlen (text);
devmsg ("setting Auto-Padding to %jd characters\n", padding_width);
}
if (*line != '\0')
{
- /* nul terminate the current field string and process */
+ /* NUL terminate the current field string and process */
+ char end_field = *line;
*line = '\0';
if (! process_field (next, field))
fputc ((delimiter == DELIMITER_DEFAULT) ?
' ' : delimiter, stdout);
- ++line;
+
+ if (delimiter != DELIMITER_DEFAULT)
+ line++;
+ else
+ {
+ *line = end_field;
+ mcel_t g = mcel_scanz (line);
+ line += g.len;
+ }
}
else
{
{ENV=>"LC_ALL=$locale"}],
['lcl-suf-6', "--from=auto '2\xe2\x81\xa0Ki'", {OUT => "2048"},
{ENV=>"LC_ALL=$locale"}],
+ # multi-byte blank char (em space, \u2003)
+ # Ensure trailing multi-byte blanks skipped
+ ['lcl-suf-7', "'2\xe2\x80\x83 '", {OUT => "2 "},
+ {ENV=>"LC_ALL=$locale"}],
+ ['lcl-suf-8', "-d '' --from=auto '2Ki\xe2\x80\x83 '", {OUT => "2048"},
+ {ENV=>"LC_ALL=$locale"}],
+ # Ensure multi-byte blank field separators not corrupted
+ ['lcl-suf-9', "--field=1 '1\xe2\x80\x832'", {OUT => "1 2"},
+ {ENV=>"LC_ALL=$locale"}],
+ ['lcl-suf-10', "--field=2 '1\xe2\x80\x832'", {OUT => "1 2"},
+ {ENV=>"LC_ALL=$locale"}],
+ # Ensure multi-byte blank field separators width determined correctly
+ ['lcl-suf-11', "--field=2 '1 \xe2\x80\x832'",
+ {OUT => "1 2"}, {ENV=>"LC_ALL=$locale"}],
);
if ($locale ne 'C')