mirror of
https://github.com/coreutils/coreutils.git
synced 2026-10-28 09:44:34 +08:00
nl: don't treat empty lines as headers with an empty -d argument
* src/nl.c (check_section): Add a check for a zero section delimiter length. * tests/nl/nl.sh: Add a test case. * NEWS: Mention the bug fix. Discovered by Anthropic's OSS Scanner, as bug ANT-2026-PDYYNTYZ.
This commit is contained in:
1 parent
266abf3fd2
commit
c242899118
3 files changed
+12
-1
No files matched your search
@@ -76,6 +76,9 @@ GNU coreutils NEWS -*- outline -*-
|
||||
just-moved FIFO.
|
||||
[bug introduced with SELinux support in coreutils-8.22]
|
||||
|
||||
'nl -d ""' no longer mistakenly treats empty lines as headers.
|
||||
[bugs introduced in coreutils-9.11]
|
||||
|
||||
od now exits gracefully when offsets overflow integer limits.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
|
||||
@@ -408,7 +408,8 @@ check_section (void)
|
||||
{
|
||||
size_t len = line_buf.length - 1;
|
||||
|
||||
if (len < section_del_len || footer_del_len < section_del_len
|
||||
if (section_del_len == 0 || len < section_del_len
|
||||
|| footer_del_len < section_del_len
|
||||
|| !memeq (line_buf.buffer, section_del, section_del_len))
|
||||
return Text;
|
||||
if (len == header_del_len
|
||||
|
||||
@@ -124,4 +124,11 @@ EOF
|
||||
compare exp-out out || fail=1
|
||||
compare exp-err err || fail=1
|
||||
|
||||
printf 'a\n\nb\n\nc' >inp || framework_failure_
|
||||
nl -d '' inp >out 2>err || fail=1
|
||||
printf ' 1\ta\n \n 2\tb\n \n 3\tc\n' >exp \
|
||||
|| framework_failure_
|
||||
compare exp out || fail=1
|
||||
compare /dev/null err || fail=1
|
||||
|
||||
Exit $fail
|
||||
Reference in new issue
Block a user