* 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.
---
NEWS | 3 +++
src/nl.c | 3 ++-
tests/nl/nl.sh | 7 +++++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index c83aeba3b..26d73fe92 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,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".]
diff --git a/src/nl.c b/src/nl.c
index 2d287b36e..0f92cfef6 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -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
diff --git a/tests/nl/nl.sh b/tests/nl/nl.sh
index 6c0a35457..88b0785e9 100755
--- a/tests/nl/nl.sh
+++ b/tests/nl/nl.sh
@@ -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
--
2.56.0