* testsuite/mb-bad-delim.sh: Don't run the sub-test that uses an
incomplete multibyte byte as a single-byte delimiter in C locale.
* testsuite/mb-y-translate.sh: Don't run the two sub-tests that
expect a y/// length-mismatch error in C locale.
Android's bionic libc uses UTF-8 even in the C locale, so these
sub-tests would always fail.
Reported by Bruno Haible in
https://lists.gnu.org/r/sed-devel/2026-04/msg00019.html
* init.cfg (remove_selinux_warning_): New function.
* testsuite/in-place-hyphen.sh: Use it before comparing stderr.
* testsuite/in-place-suffix-backup.sh: Likewise.
* testsuite/panic-tests.sh: Likewise.
* testsuite/temp-file-cleanup.sh: Likewise.
Reported by Bruno Haible in
https://lists.gnu.org/r/sed-devel/2026-04/msg00019.html
* testsuite/read-error-stale-errno.sh: Skip when a FIFO with
O_NONBLOCK returns EOF instead of EAGAIN while a writer is still
attached. Cygwin gets this wrong.
Reported by Bruno Haible in
https://lists.gnu.org/r/sed-devel/2026-04/msg00011.html
* sed/regexp.c (match_regex): Change type of 'ret' from int
to regoff_t, to avoid truncation results larger than INT_MAX.
* testsuite/regex-max-int.sh: Update this "very expensive"
test to expect correct output (bbbbb) rather than exit-code-4 panic.
* NEWS (Bug fixes): Mention this.
The following is related but mostly incidental (--debug only).
I tested via --debug, (where it generate 20GB of output!), but couldn't
easily add a test case without adding a further option to suppress
debug printing of each escaped input line.
* sed/execute.c (do_subst): Don't cast regoff_t values to (int) for
debug printing via %d. Instead, cast to (ptrdiff_t) and print via %td.
When using -i with --follow-symlinks, sed resolved the symlink via
readlink() and then opened the original symlink path in a separate
syscall. An attacker who swapped the symlink between those two
operations could cause sed to read from an attacker-controlled file
while writing the result to the originally resolved target, enabling
arbitrary file overwrite. Fix by opening the already-resolved path
rather than re-traversing the symlink.
Reported by Michał Majchrowicz and Marcin Wyczechowski (AFINE Team).
* sed/execute.c (open_next_file): Use input->in_file_name (the
resolved path) rather than "name" (the original symlink) in the
ck_fopen call.
* NEWS: Mention this.
* sed/utils.c (ck_getdelim): If the stream has the error bit already set, don't
assume that the current value of errno reflects that past failed I/O operation.
This also avoids a build failure without optimization, as mentioned in
https://lists.gnu.org/r/bug-sed/2026-04/msg00029.html
* testsuite/panic-tests.sh: Test explicitly and skip if we can
still write to a directory that's been subject to "chmod a-w".
This struck on CentOS 7, Alma Linux, Alpine Linux and Cygwin.
Reported by Bruno Haible in
https://lists.gnu.org/r/sed-devel/2026-04/msg00008.html
Surprisingly (comparing with the grep fix for this same bug), this
no-anchor case works properly both before and after the fix:
$ echo ab | sed -E 's/^(.?)(.?).?\2\1/X/'
Xb
That is because sed uses RE_NO_POSIX_BACKTRACKING, which avoids
grep's find-longest-match behavior (just fixed) that POSIX requires.
* gnulib: Update to latest for the regex bug fix.
* testsuite/backref-anchor.sh: New file. Test for this.
* testsuite/local.mk (T): Add the new file.
* NEWS (Bug fixes): Mention this.
* THANKS.in: Update.
Reported by Ed Morton in https://bugs.gnu.org/68725
sed/utils.c:236:11: error: format not a string literal, argument
types not checked [-Werror=format-nonliteral]
* configure.ac: Remove ineffective nw="$nw -Wformat-nonliteral" and
instead use targeted gl_WARN_ADD([-Wno-format-nonliteral])
With --posix, normalize_text tracks bracket-expression state to avoid
converting \X escapes inside bracket expressions. It uses p[-1] and
p[-2] to detect the closing sequence of POSIX classes like [:alpha:].
However, normalize_text operates in-place with separate read (p)
and write (q) pointers, and when an earlier \n was collapsed from
two bytes to one, q falls behind p, so p[-1] and p[-2] read positions
already overwritten by q.
E.g., with '^A\n[[:alpha:]]\n*', the first \n shrinks, putting q one
byte behind p. When processing the closing ']' in '[:alpha:]', p[-2]
reads ':' (written by q) rather than the original 'a', making the
"p[-2] != bracket_state" check fail. Then, the second \n is never
converted to a newline.
* sed/compile.c (normalize_text): Use q[-1] and q[-2] for bracket
state tracking, not p[-1] and p[-2].
* NEWS: Mention this bug fix.
* testsuite/posix-bracket-esc.sh: New test.
* testsuite/local.mk (T): Add it.
Reported by Wolfgang Jeltsch in https://debbugs.gnu.org/77786
Using --debug after -f on the command line would deref uninitialized
memory usually evoking a segfault.
* sed/compile.c (next_cmd_entry): Zero-initialize the struct.
* sed/debug.c (debug_print_function): Print only when label_name
is non-NULL.
* testsuite/debug-label.sh: New test.
* testsuite/local.mk (T): Add it.
Reported in https://debbugs.gnu.org/70232
* doc/sed.texi (BRE syntax): Note that --posix disables this GNU
extension, and clarify that in ERE mode ** is not a GNU extension.
Reported in https://debbugs.gnu.org/70476
* sed/regexp.c (compile_regex_1): Clear RE_CONTEXT_INVALID_DUP for
BRE, to accept ** as a GNU extension. In --posix mode, restore
RE_CONTEXT_INVALID_DUP for BRE to enforce strict POSIX behavior.
* NEWS: Mention this bug fix.
* testsuite/bre-star-star.sh: New test.
* testsuite/local.mk (T): Add it.
Reported in https://debbugs.gnu.org/70476
* sed/compile.c: Remove cases for 'L' command.
* testsuite/compile-errors.sh: remove test for 'L' command in posix
mode. The 'L' command was removed in version 4.3, but was still allowed
by the compiler (resulting in an internal error when running a script
that uses it). Reported in https://bugs.gnu.org/80704
Before, it would print this:
$ echo | sed L1
sed: INTERNAL ERROR: Bad cmd L
Now, it prints this:
sed: -e expression #1, char 1: unknown command: 'L'
* sed/execute.c (line_reset): Also free buf->text when buf->alloc is zero.
* testsuite/bug80573.sh: New file.
* testsuite/local.mk (T): Add it to the list.
Demonstrate via this:
echo | valgrind --leak-check=full sed/sed -e x -e 's/.*/echo hi/e' 2>&1 | grep -A5 'definitely lost'
Reported in https://bugs.gnu.org/80573
As a GNU extension, "\c[" in a regexp matches the ESC character
(i.e., control-[). Yet 's/\c[//' was rejected because "[" was treated
as the beginning of a bracket expression.
* sed/compile.c (match_slash): When matching "slash"es, treat \c as
an escape sequence, so that s/\c[// no longer fails because it
misinterprets [ as a bracket-group start.
* testsuite/misc.pl (bug79519_1,2,3,fail): Add tests.
* NEWS (Bug fixes): Mention it.
Reported by Michael Ludwig in https://bugs.gnu.org/79519.
* sed/compile.c (match_slash): Convert regex parameter from int to bool
since all callers use true or false. Add s_command parameter and warn
about nonportable backslashes when true.
(compile_address, compile_program): Update calls to match_slash.
* testsuite/posix-backslash-warn.sh: New test.
* testsuite/local.mk (T): Add it.
* NEWS: Mention the change.
* doc/sed.texi (multiple sed commands): Mention that e, r, R, w and W
are like the a, c and i commands, in that one cannot terminate such
commands with a semicolon.
* bootstrap.conf: Gnulib's stdckdint and stdbool modules are
deprecated, in favor of stdckdint-h and bool.
Induce this change with the following:
perl -pi -e 's{^stdckdint$}{$1-h};s{^stdbool$}{bool}' bootstrap.conf
And sort the resulting list of module names.