770 Commits
Author SHA1 Message Date
Jim Meyering 89b7a2224d version 4.10
* NEWS: Record release date.
v4.10
2026-04-21 18:32:56 -07:00
Jim Meyering f04e0da045 tests: skip C-locale sub-tests when "C" is multibyte
* 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
2026-04-21 08:30:31 -07:00
Jim Meyering 13604c8f68 tests: tolerate SELinux setfscreatecon warning on Android/Termux
* 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
2026-04-21 08:11:48 -07:00
Jim Meyering a8d3d77433 sed: fix two newline-lacking diagnostics
* sed/execute.c (open_next_file): Terminate each of two fprintf format
strings with "\n".
2026-04-21 07:55:02 -07:00
Brun Haible f491a1cc14 doc: fix typo in NEWS
* NEWS: s/getoph.h/getopt.h/
2026-04-21 06:20:45 -07:00
Jim Meyering 682d04b7d7 tests: skip read-error-stale-errno on Cygwin
* 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
2026-04-20 17:26:50 -07:00
Jim Meyering 6ec335494f sed: s///g now works for input lines longer than 2GB
* 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.
2026-04-20 16:59:50 -07:00
Jim Meyering 6b9b43c55c sed: -i --follow-symlinks: fix TOCTOU race (CVE-2026-5958)
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.
2026-04-20 07:47:24 -07:00
Jim Meyering fe548a4297 build: update gnulib to latest
* gnulib: Update to latest.
* lib/.gitignore: Add stdcountof.in.h.
2026-04-19 20:55:40 -07:00
Jim Meyering b99731ec2c tests: add a test for the just-fixed bug
* testsuite/read-error-stale-errno.sh: New file.
* testsuite/local.mk (T): Add it.
2026-04-19 20:17:47 -07:00
Bruno Haible a1067211a7 sed: fix invalid use of errno
* 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
2026-04-19 11:10:02 -07:00
Jim Meyering a3f33e43ad tests: avoid panic-tests failure on multiple systems
* 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
2026-04-18 22:21:48 -07:00
Jim Meyering feb70156f4 sed: a gnulib regex fix resolves long-standing backref bug
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
2026-04-18 15:40:14 -07:00
Jim Meyering 7ef6edc817 build: avoid -Wformat-nonliteral warning
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])
2026-04-18 12:29:08 -07:00
Jim Meyering 53d12197e2 sed: --posix: fix escape handling after a named character class
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
2026-04-11 16:19:38 -07:00
Bruno Haible 39c9ba576e tests: avoid test failure when running as root or in Cygwin
* testsuite/panic-tests.sh: When running as root or in Cygwin, skip the test.
2026-04-11 13:29:22 -07:00
Jim Meyering a6aebe155c sed: don't segfault for "sed -f<(echo ':label') --debug"
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
2026-04-11 13:17:39 -07:00
Jim Meyering 5eadb1976b maint: touch-ups to avoid triggering syntax-check
* doc/sed.texi (BRE syntax): Split a long line.
* lib/.gitignore: Add /stdcountof.h
2026-04-11 13:17:39 -07:00
Jim Meyering 4679c4ab6b doc: clarify ** GNU extension scope in BRE vs ERE
* 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
2026-04-11 10:42:27 -07:00
Jim Meyering 7c375a2477 sed: accept ** (documented GNU extension) in BRE mode
* 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
2026-04-11 10:35:43 -07:00
Ash Roberts 47838d29e1 sed: do not allow removed 'L' command in compiler
* 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'
2026-04-10 18:57:01 -07:00
Jim Meyering 4c067b6836 build: update gnulib to latest 2026-04-09 14:48:41 -07:00
Weixie Cui 0e2491480a sed: avoid a one-time, one-byte leak
* 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
2026-03-21 18:58:36 -07:00
Jim Meyering 3b6c162a91 tests: ensure valgrind accepts --errors-for-leak-kinds=definite
* init.cfg (require_valgrind_): Test with --errors-for-leak-kinds=definite
2026-03-21 18:58:36 -07:00
Jim Meyering cd0302744f build: update gnulib to latest; and bootstrap 2026-03-08 11:54:10 -07:00
Jim Meyering 03ec9a1080 maint: update copyright dates 2026-01-02 17:33:20 -08:00
Jim Meyering 7954732488 build: update gnulib to latest; and bootstrap 2026-01-02 17:28:28 -08:00
Jim Meyering f14b8ae84d build: update gnulib to latest; and update bootstrap 2025-11-08 12:30:35 -08:00
Jim Meyering 91c5838e33 maint: use unreachable () rather than /*NOTREACHED*/
* sed/compile.c (mark_subst_opts, compile_program): As above.
* sed/execute.c (match_an_address_p): Likewise. Also remove an
obviated "return false;".
2025-11-08 12:29:32 -08:00
Jim Meyering 1da9b546a2 doc: NEWS: the "\c[" issue was present since the beginning
* NEWS: Always attempt to list origin of a bug fix.
2025-11-08 10:42:13 -08:00
Jim Meyering e137695202 sed: do not reject "\c[" in a regular expression
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.
2025-10-01 03:20:22 -07:00
Jim Meyering f124c83561 build: update gnulib to latest 2025-10-01 03:17:14 -07:00
Bruno Haible a489d90cdc build: accommodate incoming gnulib-tests change: initialize AM_CFLAGS
* gnulib-tests/Makefile.am: Initialize AM_CFLAGS.
2025-10-01 03:15:36 -07:00
Collin Funk 1cbc273262 sed: --posix now warns about nonportable backslashes in the 's' command
* 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.
2025-08-24 16:08:17 -07:00
Hans Ginzel f1d0d1fd1d doc: correct two examples
* doc/sed.texi (Escaping Precedence): Expected output is "xbc", not
"Xbc" in each of two examples.
2025-07-09 15:09:30 -07:00
Collin Funk 4e3b320704 maint: fix Automake warning
Avoid this warning: escaping \# comment markers is not portable
* Makefile.am (prologue): Remove macro.
(THANKS): Use the perl command directly.
2025-07-08 12:36:57 -07:00
Collin Funk 240bb42225 maint: assume that compilers support '\a' as specified by C89
* sed/compile.c (normalize_text): Remove backup code for pre-C89
compilers.
* sed/execute.c (do_list): Likewise.
2025-06-26 08:12:31 -07:00
Jim Meyering b4d01a9c91 maint: ensure that new "make syntax-check"-run sc_codespell passes
* cfg.mk (codespell_ignore_words_list): Ignore false-positives.
(exclude_file_name_regexp--sc_codespell): Skip some file names.
* sed/debug.c: Fix typo(s).
* sed/mbcs.c: Likewise.
* sed/sed.c: Likewise.
* testsuite/badenc.sh: Likewise.
* testsuite/compile-errors.sh: Likewise.
* testsuite/distrib.inp: Likewise.
* testsuite/distrib.sh: Likewise.
* testsuite/execute-tests.sh: Likewise.
* testsuite/mb-bad-delim.sh: Likewise.
* testsuite/mb-charclass-non-utf8.sh: Likewise.
* testsuite/regex-max-int.sh: Likewise.
* testsuite/subst-options.sh: Likewise.
* testsuite/test-mbrtowc.c: Likewise.
* testsuite/utf8-ru.sh: Likewise.
2025-03-29 11:11:20 -07:00
Arkadiusz Drabczyk 5e9ee78fac doc: correct sentence capitalization errors
* doc/sed.texi: As above.
2025-03-09 09:18:52 -07:00
Jim Meyering 026c55f63c avoid new "make syntax-check" failures
* po/POTFILES.in: Add lib/getopt.c.
* lib/.gitignore: Add getopt-related names for recent change, and sort.
2025-03-09 09:18:44 -07:00
Collin Funk 587cfe1716 build: fix compile errors on platforms without getopt.h
* bootstrap.conf (gnulib_modules): Add getopt-gnu.
* lib/.gitignore: Update from gnulib-tool --import.
* m4/.gitignore: Likewise.
* NEWS: Mention the fix.
2025-03-03 09:06:51 -08:00
Jim Meyering 0f74c04668 doc: correct a small falsehood
* doc/sed.texi (Zero Address): Also mention the FIRST~STEP
notation as a third case in which a zero address is valid.
Reported by Arkadiusz Drabczyk in
https://lists.gnu.org/r/sed-devel/2025-02/msg00008.html
2025-02-15 21:47:20 -08:00
Jim Meyering bc120003dc build: update gnulib to latest; and update bootstrap 2025-02-15 21:03:58 -08:00
Jim Meyering 7d48e8345e sed: support gnulib-l10n
* sed/sed.c (main): Call bindtextdomain for gnulib-l10n.
2025-02-08 20:13:25 -08:00
Jim Meyering c27d1ec3de maint: continue writing base64-encoded checksums to announcement
* cfg.mk (announce_gen_args): Set to --cksum-checksums.
2025-02-08 20:09:45 -08:00
Arkadiusz Drabczyk 253c89d9d6 doc: list all commands that have to be terminated by a newline
* 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.
2025-02-04 20:10:51 -08:00
Jim Meyering 48bd45146f build: update gnulib to latest; and update bootstrap 2025-02-01 17:19:21 -08:00
Jim Meyering bb35ae5c09 maint: reflect gnulib module renamings
* 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.
2025-02-01 17:19:06 -08:00
Jim Meyering d3456f4482 maint: update all copyright dates via "make update-copyright" 2025-01-03 09:56:57 -08:00
Jim Meyering 90a04e55e7 build: update gnulib to latest, and update bootstrap 2025-01-03 09:56:24 -08:00