| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix some some longstanding but unlikely integer overflows.
Internally, 'sed' now more often prefers signed integer arithmetic,
which can be checked automatically via 'gcc -fsanitize=undefined'.
* basicdefs.h (countT): Remove. All uses replaced
with a more-specific signed type, e.g., idx_t.
Similarly, change uses of types like size_t to
signed types like idx_t when appropriate.
(REALLOC): Remove; no longer used. We now use xpalloc
because that detects integer overflow in size calculations.
Also, we no longer use XCALLOC since the code never relies
on the storage being zero, and leaving it uninitialized is
more likely to catch errors when debugging implementations
are used. We use XNMALLOC instead, or xpalloc.
* bootstrap.conf (gnulib_modules): Add stdckdint, strtoimax.
* lib/.gitignore, m4/.gitignore: Update for new Gnulib modules.
* sed/compile.c: Include stdckdint.h.
(VECTOR_ALLOC_INCREMENT): Remove; no longer used.
(in_integer): Return maximal value if integer overflow.
All callers changed to expect this.
(next_cmd_entry): Use xpalloc instead of reallocating by hand,
which might suffer integer overflow.
(normalize_text): Don’t rely on system-defined conversion
of out-of-range size_t to int.
(next_cmd_entry): Arg is now pointer, not pointer-to-pointer.
All uses changed.
* sed/debug.c (debug_print_function): Don’t attempt to
fwrite a null pointer with a zero size.
* sed/execute.c: Include <stdckdint.h>, "minmax.h".
(resize_line): LEN arg is now increment, not total length,
to avoid overflow when calculating total length.
All uses changed. Do not assume lb->alloc * 2 cannot overflow.
(resize_line, line_copy): Use xpalloc instead of doing realloc by
hand, which might suffer integer overflow.
(str_append_modified): Do not add n to to->length until
after it's known this cannot overflow.
(read_file_line): Don’t assume ssize_t fits in long.
(get_backup_file_name): Don’t assume string length fits in int.
Do not assume PTR-1+1 works; behavior is undefined if PTR
is at buffer start. Check for integer overflow in buffer
size calculation.
(read_pattern_space): Check for line number overflow.
(match_address_p): Check for address overflow.
(debug_print_line): Omit unnecessary test for in->active being null.
(execute_program): Check for Q overflow.
* sed/regexp.c: Include <stdckdint.h>.
(match_regex): Don’t assume TYPE_MAXIMUM (regoff_t) == INT_MAX.
* sed/sed.c: Include inttypes.h, for strtoimax.
(main): Use strtoimax, not atoi.
* sed/utils.c (init_buffer): Use xmalloc and xpalloc
instead of guessing sizes ourselves, and unnecessarily
initializing.
(resize_buffer): Remove; all callers changed to use xpalloc.
(free_buffer): Don’t call free (NULL), since we already
test whether the pointer is null.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Without this fix, the code would sometimes use FP after calling
fclose (FP), which has undefined behavior in C.
Problem found with --enable-gcc-warnings and GCC 12.
* sed/execute.c (open_next_file): Do not register here,
as it’s too late and this can cause the file to not
be cleaned up.
* sed/sed.c (G_file_to_unlink, register_cleanup_file, cancel_cleanup):
Move from here to utils.c.
(cleanup): Call remove_cleanup_file instead of doing it by hand.
* sed/utils.c (struct open_file): Remove member temp
(which was always false) and fclose_failed (which was
not enough to prevent calling fclose with a bad pointer).
All uses changed.
(register_open_file): Do not access p->fp after it’s fclosed,
as that has undefined behavior in C.
Use xmalloc instead of xcalloc, since we initialize all members.
(G_file_to_unlink, register_cleanup_file, cancel_cleanup):
Move from utils.c to here.
(remove_cleanup_file): New function.
(ck_mkstemp): Fix a screwup when mkostemp succeeded but
set_binary_mode or fdopen failed: we might misuse a null pointer,
or forget to clean up the newly-created temp file.
(ck_getdelim): Rename local to avoid confusion with global.
(mark_as_fclose_failed): Remove. All uses removed.
(ck_fclose): Remove entry from open_files before attempting
to fclose it, so that panicking doesn’t try to fclose it again.
(do_ck_fclose): New arg NAME so that there’s no need to
call mark_as_fclose_failed, which inspected FP after fclosing
it, which is undefined behavior.
(ck_rename): Omit arg UNLINK_IF_FAIL. All callers changed.
The cleanup handler removes this file now, as needed.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Run "make update-copyright" and then...
* gnulib: Update to latest with copyright year adjusted.
* bootstrap.conf (gnulib_modules): Remove getopt module, depracated in
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=0abc38bd2a1398f0
* po/POTFILES.in: Remove getopt.c
* sed/utils.h (panic): Rename _GL_ATTRIBUTE_FORMAT_PRINTF to
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD following gnulib's change:
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=387d654cabd7bc15
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
|
|
|
|
|
|
|
| |
Run "make update-copyright" and then...
* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
|
|
|
|
| |
* all files: Run "make update-copyright".
|
|
|
|
|
|
|
| |
* basicdefs.h, sed/compile.c, sed/execute.c, sed/mbcs.c, sed/regexp.c,
sed/sed.c, sed/sed.h, sed/utils.c, sed/utils.h, testsuite/get-mb-cur-max.c,
testsuite/test-mbrtowc.c (GPL License notice): Replace FSF's office
address with 'https://www.gnu.org/licenses/'.
|
|
|
|
|
|
|
|
|
| |
* compile.c (bad_prog): Use program_name instead of myname.
* execute.c (open_next_file): Same.
* utils.c (panic): Same.
(myname): Remove variable.
* sed.c (usage): Use program_name instead of myname.
(main): Call set_program_name once, don't set variables directly.
|
|
|
|
|
|
| |
* sed/utils.{c,h} (ck_strdup): Remove.
* sed/compile.c, sed/execute.c, sed/sed.c: Replace ck_strdup with
xstrdup.
|
|
|
|
|
|
| |
* bootstrap.conf: Add gnulib's xalloc module.
* basicdefs.h (MEMDUP): Remove.
* sed/utils.{c,h} (ck_memdup): Remove.
|
|
|
|
|
| |
* gnulib: Update to latest.
* all files: Run "make update-copyright".
|
|
|
|
|
| |
* gnulib: Update to latest.
* all files: Run "make update-copyright".
|
|
|
|
|
|
|
|
|
| |
* sed/utils.h (panic): Add __printf__ attribute, so that compilers
can diagnose format/arg-type errors. This exposed the following:
* sed/utils.c (ck_fwrite): Don't try to print size_t via %u.
Instead, use %llu and a cast to unsigned long long.
* sed/mbcs.c (is_mb_char): Cast an "int" to unsigned int, to avoid
mismatch with %x.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use exit-code constants, and document them:
1=syntax error, 2=bad input files, 4=I/O error or panic.
Add "Exit Status" section in manual.
* sed/utils.h: Define new constants.
* sed/utils.c,
sed/compile.c,
sed/execute.c,
sed/sed.c: Use constants instead of hard-coded values.
* doc/sed-in.texi: Add "Exit Status" section.
* doc/sed.texi: Automatically re-generated.
|
|
|
|
|
|
|
|
| |
Run "make update-copyright" and then...
* gnulib: Update to latest.
* tests/init.sh: Update from gnulib.
* bootstrap: Likewise.
|
|
|
|
|
|
|
|
|
|
| |
* sed/utils.c (ck_mkstemp): Remove $TMP/$TMPDIR-envvar-using code
that would have been run only if this function's second parameter
were to be NULL, but that could never happen, given the current
and sole caller.
Also, use mode_t as the type for the saved umask value, not "int".
Also, move each declaration down to point of definition.
* sed/utils.h (ck_mkstemp): Mark each of the four parameters as nonnull.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* cfg.mk (local-checks-to-skip): Remove the overall exemption,
but continue to exempt some files in testsuite/.
* configure.ac: Split a long line.
* doc/sed-in.texi: Split long lines.
* doc/sed.texi: Likewise.
* sed/compile.c: Likewise.
* sed/execute.c: Split long lines.
(execute_program): Reorder "#ifdef HAVE_POPEN" and
"if (pipe_fp != NULL)" if/else blocks to make the code
clearer and (incidentally) the lines shorter, due to a
decrease in nesting level.
* sed/sed.c: Split long lines.
* sed/utils.c: Likewise.
* sed/utils.h: Likewise.
|
| |
|
|
|
|
|
|
|
| |
* sed/utils.h (get_buffer, size_buffer): Make each functions
sole parameter "const" and declare the function itself with the
"pure" attribute.
* sed/utils.c (get_buffer, size_buffer): Adjust definitions to match.
|
|
|
|
|
|
| |
This avoids two gcc may-be-noreturn warnings:
* sed/sed.h (bad_prog): Add _Noreturn attribute.
* sed/utils.h (panic): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* cfg.mk (local-checks-to-skip): Remove its exemption.
Exempt all files under testsuite/, for now, and a few others.
* .gitmodules: Change each leading TAB to 8 spaces spaces.
* BUGS: Likewise.
* NEWS: Likewise.
* configure.ac: Likewise.
* sed/compile.c: Likewise.
* sed/execute.c: Likewise.
* sed/fmt.c: Likewise.
* sed/regexp.c: Likewise.
* sed/sed.c: Likewise.
* sed/sed.h: Likewise.
* sed/utils.c: Likewise.
* sed/utils.h: Likewise.
* COPYING: Update from coreutils.
|
|
|
|
|
|
| |
* bootstrap.conf (gnulib_modules): Add update-copyright.
Then, run "make update-copyright".
* Makefile.am: Add copyright header.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
2012-03-16 Paolo Bonzini <bonzini@gnu.org>
* basicdefs.h (P_): Remove.
* sed/compile.c: Adjust.
* sed/execute.c: Likewise.
* sed/fmt.c: Likewise.
* sed/sed.c: Likewise.
* sed/sed.h: Likewise.
* sed/utils.c: Likewise.
* sed/utils.h: Likewise.
|
|
|
|
|
|
|
|
|
|
|
| |
2012-03-16 Paolo Bonzini <bonzini@gnu.org>
* basicdefs.h (FREE): Remove.
* sed/compile.c: Adjust.
* sed/execute.c: Adjust.
* sed/regexp.c: Adjust.
* sed/utils.c: Adjust, remove ck_free.
* sed/utils.h: Adjust, remove ck_free.
|
|
|
|
|
|
|
|
|
|
|
| |
2012-03-16 Paolo Bonzini <bonzini@gnu.org>
* basicdefs.h (CAST, VCAST, VOID, MEMCPY, MEMMOVE): Rip out.
* sed/compile.c: Adjust.
* sed/execute.c: Adjust.
* sed/regexp.c: Adjust.
* sed/utils.c: Adjust.
* sed/utils.h: Adjust.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
2012-02-05 Paolo Bonzini <bonzini@gnu.org>
Jim Hill <gjthill@gmail.com>
* autoboot.conf: Change getline to getdelim.
* doc/sed-in.texi: Document -z/--null-data.
* doc/sed.texi: Regenerate.
* sed/execute.c: Change '\n' to buffer_delimiter.
* sed/sed.c: Add support for -z/--null-data.
* sed/sed.h: Add buffer_delimiter.
* sed/utils.c: Change ck_getline to ck_getdelim.
* sed/utils.h: Change ck_getline to ck_getdelim.
* NEWS: Document new option.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
2010-07-18 Paolo Bonzini <bonzini@gnu.org>
* sed.c (write_mode): New.
(main): Initialize it to "wb" if --binary is passed.
* sed.h (write_mode): New.
* compile.c (mark_subst_opts, compile_program): Use it instead
of "w".
* execute.c (open_next_file): Pass write_mode to ck_mkstemp.
* utils.c (ck_mkstemp): Accept mode, pass it to fdopen. Constify.
* utils.h (ck_mkstemp): Adjust prototype.
|
|
|
|
|
|
|
|
|
| |
2009-04-30 Paolo Bonzini <bonzini@gnu.org>
* sed/compile.c: Declare bool arguments as int instead to please AIX XLC.
* sed/execute.c: Declare bool arguments as int instead to please AIX XLC.
* sed/utils.c: Declare bool arguments as int instead to please AIX XLC.
* sed/utils.h: Declare bool arguments as int instead to please AIX XLC.
|
|
|
|
| |
git-archimport-id: bonzini@gnu.org--2004b/sed--stable--4.1--patch-94
|
|
|
|
|
|
|
|
| |
2006-12-15 Paolo Bonzini <bonzini@gnu.org>
* sed/regexp.c: Disable all extensions on --posix.
git-archimport-id: bonzini@gnu.org--2004b/sed--stable--4.1--patch-84
|
|
2006-09-24 Paolo Bonzini <bonzini@gnu.org>
* sed/execute.c: Support ACLs.
* lib/utils.c: Move...
* sed/utils.c: ... here, and remove xmalloc.
git-archimport-id: bonzini@gnu.org--2004b/sed--stable--4.1--patch-74
|