diff --git a/NEWS b/NEWS index cfaaab404..64f6b0bfc 100644 --- a/NEWS +++ b/NEWS @@ -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".] 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