From 4f2595eff38f6e4552edb4c4d86f30255c59dc01 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Thu, 28 Mar 2024 12:16:15 -0400 Subject: [PATCH] more fixes for using bool and the stdckdint functions for integer overflow; another update to test from coreutils-9.2 changes; fix memleak in parser state on parse error; Makefile changes for macOS --- CWRU/CWRU.chlog | 80 ++++++++++++++++++++++++++++++++++++++++-- MANIFEST | 1 + Makefile.in | 13 ++++--- bashansi.h | 24 ++++++++++--- braces.c | 11 +++--- builtins/fc.def | 4 ++- builtins/help.def | 4 +-- builtins/history.def | 4 ++- builtins/printf.def | 17 ++++----- configure | 16 ++++++++- configure.ac | 3 +- doc/bash.1 | 5 +-- doc/bashref.texi | 1 + doc/version.texi | 6 ++-- externs.h | 5 ++- lib/readline/shell.c | 4 --- lib/sh/Makefile.in | 6 +++- lib/sh/fmtulong.c | 5 +-- lib/sh/getcwd.c | 6 +--- lib/sh/makepath.c | 6 +--- lib/sh/reallocarray.c | 44 +++++++++++++++++++++++ lib/sh/snprintf.c | 5 +-- lib/sh/stringvec.c | 29 ++++++--------- lib/sh/strtod.c | 6 +--- lib/sh/strtol.c | 6 +--- parse.y | 25 +++++++++++++ po/de.gmo | Bin 145872 -> 153703 bytes po/de.po | 42 +++++++++++++--------- shell.h | 3 +- test.c | 18 +++++++--- unwind_prot.c | 10 +----- xmalloc.c | 34 +++++++++++++++--- xmalloc.h | 5 ++- 33 files changed, 320 insertions(+), 128 deletions(-) create mode 100644 lib/sh/reallocarray.c diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 725b576b..8f18eaa1 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -8920,6 +8920,80 @@ test.c - term: if we see a left paren, scan forward for a closing right paren and use posixtest() if there are 1-4 arguments between the parens to avoid ambiguous behavior for expressions like true -a \( ! -a \), - which a user would expect to return false instead of an error - message - Picked up from coreutils test + which, though it's horribly ambiguous, a user would expect to + return false instead of an error message + Picked up from coreutils-9.2 test + + 3/25 + ---- +bashansi.c + - HAVE_C_BOOL: prefer if defined, fall back to stdbool.h if bool isn't + a compiler builtin + +braces.c + - mkseq: simplify break condition + +builtins/printf.def + - decodeint: let the caller decide what to do with an overflow return, + don't return -1 after calling report_erange(). This will honor a + precision even if the field width overflows + - printf_builtin: check for overflow when adjusting precision for + string length with %Q + - printstr,printwidestr: now that the code uses decodeint, we don't + need to check the precision against INT_MAX + +bashansi.h + - include stddef.h if we have it, otherwise define replacements for + NULL and offsetof() + +builtins/help.def,lib/sh/fmtulong.c,lib/sh/getcwd.c,lib/sh/makepath.c, +lib/sh/snprintf.c,lib/sh/strtod.c,lib/sh/strtol.c,unwind_prot.c, +lib/readline/shell.c + - include bashansi.h instead of stddef.h, or remove a stddef.h include + if bashansi.h is already included + - remove extra definitions that appear in stddef.h or bashansi.h + +lib/sh/reallocarray.c,externs.h + - implementation of reallocarray(), originally from OpenBSD, from + Paul Eggert + +configure.ac + - use AC_REPLACE_FUNCS for reallocarray + +xmalloc.c,xmalloc.h + - xreallocarray: implementation of reallocarray that uses xrealloc + - sh_xreallocarray: implementation of reallocarray that uses + sh_xrealloc and has file and line information for error messages + +lib/sh/stringvec.c + - strvec_create, strvec_resize: rewrite in terms of xreallocarray + - strvec_mcreate, strvec_mresize: rewrite in terms of reallocarray + - strvec_remove, strvec_search, strvec_copy, strvec_from_word_list, + strvec_to_word_list: use size_t instead of int where appropriate + +lib/sh/stringvec.c,externs.h + - strvec_search: return a value of type ptrdiff_t, since size_t is + unsigned and we want to return -1 if not found + + All from a report and patch by Paul Eggert + +test.c + - term: change paren scan algorithm to count open and close parens so + we handle nested subexpressions. Still not compatible in the case + of something like test true -a \( ! -a \) \) + + 3/27 + ---- +parse.y + - flush_parser_state: new function, deallocates the members of a + parser state struct that are dynamically allocated + - parse_comsub: call flush_parser_state in places where we will + return an error or jump to the top level + Fixes memory leaks on error reported by bug_reports00@protonmail.com + +Makefile.in + - CREATED_MACOS: list of dSYM directories created by building and + testing + - distclean,maintainer-clean: remove $(CREATED_HEADERS) and + $(CREATED_MACOS) + - maintainer-clean: remove ctags/etags files diff --git a/MANIFEST b/MANIFEST index c1f079ee..1d4dee59 100644 --- a/MANIFEST +++ b/MANIFEST @@ -466,6 +466,7 @@ lib/sh/oslib.c f lib/sh/pathcanon.c f lib/sh/pathphys.c f lib/sh/random.c f +lib/sh/reallocarray.c f lib/sh/rename.c f lib/sh/setlinebuf.c f lib/sh/shmatch.c f diff --git a/Makefile.in b/Makefile.in index 7499e897..8069162a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile for bash-5.3, version 5.4 +# Makefile for bash-5.3, version 5.5 # # Copyright (C) 1996-2024 Free Software Foundation, Inc. @@ -583,6 +583,8 @@ CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \ mksignames$(EXEEXT) lsignames.h \ mksyntax${EXEEXT} syntax.c $(VERSPROG) $(VERSOBJ) \ buildversion.o mksignames.o signames.o buildsignames.o +CREATED_MACOS = recho.dSYM zecho.dSYM printenv.dSYM xcase.dSYM \ + bashversion.dSYM mksyntax.dSYM ${DEFDIR}/psize.aux.dSYM CREATED_CONFIGURE = config.h config.cache config.status config.log \ stamp-h po/POTFILES config.status.lineno CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \ @@ -949,6 +951,7 @@ clean: basic-clean -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) $(RM) $(CREATED_SUPPORT) + $(RM) -rf $(CREATED_MACOS) mostlyclean: basic-clean ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) @@ -970,7 +973,8 @@ distclean: basic-clean maybe-clean -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) $(RM) $(CREATED_CONFIGURE) tags TAGS - $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) pathnames.h + $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) $(CREATED_HEADERS) + $(RM) -rf $(CREATED_MACOS) maintainer-clean: basic-clean @echo This command is intended for maintainers to use. @@ -984,8 +988,9 @@ maintainer-clean: basic-clean done -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) - $(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES) - $(RM) $(CREATED_SUPPORT) Makefile pathnames.h + $(RM) $(CREATED_CONFIGURE) Makefile $(CREATED_MAKEFILES) tags TAGS + $(RM) $(CREATED_SUPPORT) $(CREATED_HEADERS) + $(RM) -rf $(CREATED_MACOS) maybe-clean: -if test X"`cd $(topdir) && pwd -P`" != X"`cd $(BUILD_DIR) && pwd -P`" ; then \ diff --git a/bashansi.h b/bashansi.h index 4feaadfb..16772d22 100644 --- a/bashansi.h +++ b/bashansi.h @@ -35,14 +35,28 @@ # include "ansi_stdlib.h" #endif /* !HAVE_STDLIB_H */ -/* Prefer stdbool.h if we have it, maybe have to rethink this later */ -#if defined (HAVE_STDBOOL_H) -# include -#else -# ifndef HAVE_C_BOOL +/* If bool is not a compiler builtin, prefer stdbool.h if we have it */ +#if !defined (HAVE_C_BOOL) +# if defined (HAVE_STDBOOL_H) +# include +# else # undef bool typedef unsigned char bool; +# define true 1 +# define false 0 # endif #endif +/* Include , or define substitutes (config.h handles ptrdiff_t). */ +#ifdef HAVE_STDDEF_H +# include +#endif +/* Substitutes for definitions in stddef.h */ +#ifndef NULL +# define NULL 0 +#endif +#ifndef offsetof +# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + #endif /* !_BASHANSI_H_ */ diff --git a/braces.c b/braces.c index 444807a7..099312e4 100644 --- a/braces.c +++ b/braces.c @@ -399,7 +399,7 @@ mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width) QUIT; #endif if (type == ST_INT) - result[i++] = t = itos (n); + t = itos (n); else if (type == ST_ZINT) { size_t tlen; @@ -419,7 +419,6 @@ mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width) memset (t + (n < 0), '0', width - tlen); } } - result[i++] = t; } else { @@ -428,9 +427,10 @@ mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width) t[0] = n; t[1] = '\0'; } - result[i++] = t; } + result[i++] = t; + /* We failed to allocate memory for this number, so we bail. */ if (t == 0) { @@ -445,11 +445,8 @@ mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width) } n += incr; - - if (i == nelem - 1) - break; } - while (1); + while (i < nelem - 1); result[i] = (char *)0; return (result); diff --git a/builtins/fc.def b/builtins/fc.def index d5f7beaa..17121037 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -1,7 +1,7 @@ This file is fc.def, from which is created fc.c. It implements the builtin "fc" in Bash. -Copyright (C) 1987-2023 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -45,6 +45,8 @@ A useful alias to use with this is r='fc -s', so that typing `r cc' runs the last command beginning with `cc' and typing `r' re-executes the last command. +The history builtin also operates on the history list. + Exit Status: Returns success or status of executed command; non-zero if an error occurs. $END diff --git a/builtins/help.def b/builtins/help.def index 6195831b..0831cab0 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -1,7 +1,7 @@ This file is help.def, from which is created help.c. It implements the builtin "help" in Bash. -Copyright (C) 1987-2023 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -58,7 +58,7 @@ $END #include #include -#include +#include "../bashansi.h" #include "../bashintl.h" diff --git a/builtins/history.def b/builtins/history.def index 69203a92..ae64726a 100644 --- a/builtins/history.def +++ b/builtins/history.def @@ -1,7 +1,7 @@ This file is history.def, from which is created history.c. It implements the builtin "history" in Bash. -Copyright (C) 1987-2023 Free Software Foundation, Inc. +Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -50,6 +50,8 @@ if HISTFILE has a value, that is used. If FILENAME is not supplied and HISTFILE is unset or null, the -a, -n, -r, and -w options have no effect and return success. +The fc builtin also operates on the history list. + If the HISTTIMEFORMAT variable is set and not null, its value is used as a format string for strftime(3) to print the time stamp associated with each displayed history entry. No time stamps are printed otherwise. diff --git a/builtins/printf.def b/builtins/printf.def index c033407b..91b76d6e 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -262,10 +262,7 @@ decodeint (char **str, int diagnose, int overflow_return) v |= ckd_add (&pr, pr, *ps - '0'); } if (v && diagnose) - { - report_erange (*str, ps); - return -1; - } + report_erange (*str, ps); *str = ps; return (v ? overflow_return : pr); @@ -699,8 +696,12 @@ printf_builtin (WORD_LIST *list) slen = strlen (xp); if (convch == 'Q') { - if (slen > precision) - precision = slen; + /* check for string length overflow when adjusting precision */ + if (ckd_add (&precision, slen, 0)) + { + builtin_error (_("%%Q: string length: %s"), strerror (ERANGE)); + precision = -1; + } } /* Use printstr to get fieldwidth and precision right. */ r = printstr (start, xp, slen, fieldwidth, precision); @@ -904,7 +905,7 @@ printstr (char *fmt, char *string, size_t len, int fieldwidth, int precision) pr = decodeint (&fmt, 1, -1); /* pr < precision means we adjusted precision in printf_builtin for the quoted string length (%Q), so we use the adjusted value */ - if (pr < precision && precision < INT_MAX) + if (pr < precision) pr = precision; } else @@ -1002,7 +1003,7 @@ printwidestr (char *fmt, wchar_t *wstring, size_t len, int fieldwidth, int preci pr = decodeint (&fmt, 1, -1); /* pr < precision means we adjusted precision in printf_builtin for the quoted string length (%Q), so we use the adjusted value */ - if (pr < precision && precision < INT_MAX) + if (pr < precision) pr = precision; } else diff --git a/configure b/configure index 6f6c0150..d70968da 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Bash 5.3, version 5.062. +# From configure.ac for Bash 5.3, version 5.063. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.71 for bash 5.3-devel. # @@ -15865,6 +15865,20 @@ esac fi +ac_fn_c_check_func "$LINENO" "reallocarray" "ac_cv_func_reallocarray" +if test "x$ac_cv_func_reallocarray" = xyes +then : + printf "%s\n" "#define HAVE_REALLOCARRAY 1" >>confdefs.h + +else $as_nop + case " $LIBOBJS " in + *" reallocarray.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS reallocarray.$ac_objext" + ;; +esac + +fi + ac_fn_c_check_header_compile "$LINENO" "libaudit.h" "ac_cv_header_libaudit_h" "$ac_includes_default" if test "x$ac_cv_header_libaudit_h" = xyes diff --git a/configure.ac b/configure.ac index dd276b68..b1fd617a 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script. # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AC_REVISION([for Bash 5.3, version 5.062])dnl +AC_REVISION([for Bash 5.3, version 5.063])dnl define(bashvers, 5.3) define(relstatus, devel) @@ -887,6 +887,7 @@ AC_REPLACE_FUNCS(dprintf) AC_REPLACE_FUNCS(strchrnul) AC_REPLACE_FUNCS(strdup) AC_REPLACE_FUNCS(strlcpy) +AC_REPLACE_FUNCS(reallocarray) AC_CHECK_HEADERS(libaudit.h) AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include ]]) diff --git a/doc/bash.1 b/doc/bash.1 index 65bd81ce..3a03578b 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -5,14 +5,14 @@ .\" Case Western Reserve University .\" chet.ramey@case.edu .\" -.\" Last Change: Mon Feb 19 16:52:45 EST 2024 +.\" Last Change: Mon Mar 25 10:56:35 EDT 2024 .\" .\" bash_builtins, strip all but Built-Ins section .\" avoid a warning about an undefined register .\" .if !rzY .nr zY 0 .if \n(zZ=1 .ig zZ .if \n(zY=1 .ig zY -.TH BASH 1 "2024 February 19" "GNU Bash 5.3" +.TH BASH 1 "2024 March 25" "GNU Bash 5.3" .\" .\" There's some problem with having a `@' .\" in a tagged paragraph with the BSD man macros. @@ -3683,6 +3683,7 @@ Produces a possibly-quoted version of the value of \fIparameter\fP, except that it prints the values of indexed and associative arrays as a sequence of quoted key-value pairs (see \fBArrays\fP above). +The keys and values are quoted in a format that can be reused as input. .TP .B a The expansion is a string consisting of flag values representing diff --git a/doc/bashref.texi b/doc/bashref.texi index adfd7346..0cd70978 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -2609,6 +2609,7 @@ Produces a possibly-quoted version of the value of @var{parameter}, except that it prints the values of indexed and associative arrays as a sequence of quoted key-value pairs (@pxref{Arrays}). +The keys and values are quoted in a format that can be reused as input. @item a The expansion is a string consisting of flag values representing @var{parameter}'s attributes. diff --git a/doc/version.texi b/doc/version.texi index a0bd72ca..f5c22ce8 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -2,10 +2,10 @@ Copyright (C) 1988-2024 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Mon Feb 19 16:52:26 EST 2024 +@set LASTCHANGE Mon Mar 25 10:56:49 EDT 2024 @set EDITION 5.3 @set VERSION 5.3 -@set UPDATED 19 February 2024 -@set UPDATED-MONTH February 2024 +@set UPDATED 25 March 2024 +@set UPDATED-MONTH March 2024 diff --git a/externs.h b/externs.h index b60fb79e..bc6f5cc1 100644 --- a/externs.h +++ b/externs.h @@ -333,6 +333,9 @@ extern void seedrand (void); /* seed generator randomly */ extern void seedrand32 (void); extern u_bits32_t get_urandom32 (void); +/* declarations for functions defined in lib/sh/reallocarray.c */ +extern void *reallocarray (void *, size_t, size_t); + /* declarations for functions defined in lib/sh/setlinebuf.c */ #ifdef NEED_SH_SETLINEBUF_DECL extern int sh_setlinebuf (FILE *); @@ -429,7 +432,7 @@ extern void strvec_flush (char **); extern void strvec_dispose (char **); extern int strvec_remove (char **, const char *); extern size_t strvec_len (char * const *); -extern int strvec_search (char **, const char *); +extern ptrdiff_t strvec_search (char **, const char *); extern char **strvec_copy (char * const *); extern int strvec_posixcmp (char **, char **); extern int strvec_strcmp (char **, char **); diff --git a/lib/readline/shell.c b/lib/readline/shell.c index 36c91484..7c0f9554 100644 --- a/lib/readline/shell.c +++ b/lib/readline/shell.c @@ -67,10 +67,6 @@ extern struct passwd *getpwuid (uid_t); #endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */ -#ifndef NULL -# define NULL 0 -#endif - #ifndef CHAR_BIT # define CHAR_BIT 8 #endif diff --git a/lib/sh/Makefile.in b/lib/sh/Makefile.in index f0088477..c57052e7 100644 --- a/lib/sh/Makefile.in +++ b/lib/sh/Makefile.in @@ -95,7 +95,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \ ufuncs.c casemod.c dprintf.c input_avail.c mbscasecmp.c fnxform.c \ strchrnul.c unicode.c wcswidth.c wcsnwidth.c shmbchar.c strdup.c \ strvis.c strlcpy.c strscpy.c utf8.c random.c gettimeofday.c \ - timers.c anonfile.c compat.c + timers.c anonfile.c reallocarray.c compat.c # The header files for this library. HSOURCES = @@ -178,6 +178,7 @@ oslib.o: oslib.c pathcanon.o: pathcanon.c pathphys.o: pathphys.c random.o: random.c +reallocarray.o: reallocarray.c rename.o: rename.c setlinebuf.o: setlinebuf.c shmatch.o: shmatch.c @@ -265,6 +266,7 @@ oslib.o: ${BUILD_DIR}/config.h pathcanon.o: ${BUILD_DIR}/config.h pathphys.o: ${BUILD_DIR}/config.h random.o: ${BUILD_DIR}/config.h +reallocarray.o: ${BUILD_DIR}/config.h rename.o: ${BUILD_DIR}/config.h setlinebuf.o: ${BUILD_DIR}/config.h shmatch.o: ${BUILD_DIR}/config.h @@ -691,6 +693,8 @@ anonfile.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h anonfile.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h anonfile.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h +reallocarray.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h + compat.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h compat.o: ${topdir}/bashtypes.h compat.o: ${BASHINCDIR}/filecntl.h diff --git a/lib/sh/fmtulong.c b/lib/sh/fmtulong.c index 329e48c7..89f0416c 100644 --- a/lib/sh/fmtulong.c +++ b/lib/sh/fmtulong.c @@ -1,6 +1,6 @@ /* fmtulong.c -- Convert unsigned long int to string. */ -/* Copyright (C) 1998-2011,2023 Free Software Foundation, Inc. +/* Copyright (C) 1998-2011,2023-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -31,9 +31,6 @@ #endif #include -#ifdef HAVE_STDDEF_H -# include -#endif #ifdef HAVE_STDINT_H # include diff --git a/lib/sh/getcwd.c b/lib/sh/getcwd.c index 1a39b9f6..a3a1f8b5 100644 --- a/lib/sh/getcwd.c +++ b/lib/sh/getcwd.c @@ -1,6 +1,6 @@ /* getcwd.c -- get pathname of current directory */ -/* Copyright (C) 1991, 2022 Free Software Foundation, Inc. +/* Copyright (C) 1991, 2022, 2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -64,10 +64,6 @@ extern int errno; # define lstat stat #endif -#if !defined (NULL) -# define NULL 0 -#endif - /* If the d_fileno member of a struct dirent doesn't return anything useful, we need to check inode number equivalence the hard way. Return 1 if the inode corresponding to PATH/DIR is identical to THISINO. */ diff --git a/lib/sh/makepath.c b/lib/sh/makepath.c index af3adefa..145559b4 100644 --- a/lib/sh/makepath.c +++ b/lib/sh/makepath.c @@ -1,6 +1,6 @@ /* makepath.c - glue PATH and DIR together into a full pathname. */ -/* Copyright (C) 1987-2020,2022-2023 Free Software Foundation, Inc. +/* Copyright (C) 1987-2020,2022-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -32,10 +32,6 @@ #include -#ifndef NULL -# define NULL 0 -#endif - /* MAKE SURE THESE AGREE WITH ../../externs.h. */ #ifndef MP_DOTILDE diff --git a/lib/sh/reallocarray.c b/lib/sh/reallocarray.c new file mode 100644 index 00000000..53d7f779 --- /dev/null +++ b/lib/sh/reallocarray.c @@ -0,0 +1,44 @@ +/* reallocarray.c - reallocate memory for an array given type size and + number of elements */ + +/* Copyright (C) 2024 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see . +*/ + +#include + +#include "bashansi.h" +#include + +#include +#if !defined (errno) +extern int errno; +#endif + +void * +reallocarray (void *ptr, size_t nmemb, size_t size) +{ + size_t nbytes; + + if (ckd_mul (&nbytes, nmemb, size)) + { + errno = ENOMEM; + return NULL; + } + + return realloc (ptr, nbytes); +} diff --git a/lib/sh/snprintf.c b/lib/sh/snprintf.c index d0363dcb..e8814b95 100644 --- a/lib/sh/snprintf.c +++ b/lib/sh/snprintf.c @@ -9,7 +9,7 @@ Unix snprintf implementation. derived from inetutils/libinetutils/snprintf.c Version 1.1 - Copyright (C) 2001-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -94,9 +94,6 @@ # include #endif #include -#ifdef HAVE_STDDEF_H -# include -#endif #include #ifdef HAVE_STDINT_H diff --git a/lib/sh/stringvec.c b/lib/sh/stringvec.c index 10ca9da7..193a26f9 100644 --- a/lib/sh/stringvec.c +++ b/lib/sh/stringvec.c @@ -37,34 +37,26 @@ char ** strvec_create (size_t n) { - size_t nbytes; - - return ckd_mul (&nbytes, n, sizeof (char *)) ? NULL : xmalloc (nbytes); + return ((char **)xreallocarray (NULL, n, sizeof (char *))); } /* Allocate an array of strings with room for N members. */ char ** strvec_mcreate (size_t n) { - size_t nbytes; - - return ckd_mul (&nbytes, n, sizeof (char *)) ? NULL : malloc (nbytes); + return ((char **)reallocarray (NULL, n, sizeof (char *))); } char ** strvec_resize (char **array, size_t nsize) { - size_t nbytes; - - return ckd_mul (&nbytes, nsize, sizeof (char *)) ? NULL : (char **)xrealloc (array, nbytes); + return ((char **)xreallocarray (array, nsize, sizeof (char *))); } char ** strvec_mresize (char **array, size_t nsize) { - size_t nbytes; - - return ckd_mul (&nbytes, nsize, sizeof (char *)) ? NULL : (char **)realloc (array, nbytes); + return ((char **)reallocarray (array, nsize, sizeof (char *))); } /* Return the length of ARRAY, a NULL terminated array of char *. */ @@ -103,7 +95,7 @@ strvec_dispose (char **array) int strvec_remove (char **array, const char *name) { - register int i, j; + size_t i, j; char *x; if (array == 0) @@ -123,10 +115,10 @@ strvec_remove (char **array, const char *name) /* Find NAME in ARRAY. Return the index of NAME, or -1 if not present. ARRAY should be NULL terminated. */ -int +ptrdiff_t strvec_search (char **array, const char *name) { - int i; + size_t i; for (i = 0; array[i]; i++) if (STREQ (name, array[i])) @@ -139,8 +131,7 @@ strvec_search (char **array, const char *name) char ** strvec_copy (char * const *array) { - int i; - size_t len; + size_t i, len; char **ret; len = strvec_len (array); @@ -212,7 +203,7 @@ strvec_sort (char **array, int posix) char ** strvec_from_word_list (WORD_LIST *list, int alloc, int starting_index, int *ip) { - int count; + size_t count; char **array; count = list_length ((GENERIC_LIST *)list); @@ -239,7 +230,7 @@ strvec_to_word_list (char **array, int alloc, int starting_index) { WORD_LIST *list; WORD_DESC *w; - int i, count; + size_t i, count; if (array == 0 || array[0] == 0) return (WORD_LIST *)NULL; diff --git a/lib/sh/strtod.c b/lib/sh/strtod.c index e6c1c360..fec80d2e 100644 --- a/lib/sh/strtod.c +++ b/lib/sh/strtod.c @@ -1,6 +1,6 @@ /* strtod.c - convert string to double-precision floating-point value. */ -/* Copyright (C) 1991, 1992, 2022 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 2022-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -41,10 +41,6 @@ extern int errno; #include -#ifndef NULL -# define NULL 0 -#endif - #ifndef HUGE_VAL # define HUGE_VAL HUGE #endif diff --git a/lib/sh/strtol.c b/lib/sh/strtol.c index ac30dbd9..7b6427ec 100644 --- a/lib/sh/strtol.c +++ b/lib/sh/strtol.c @@ -1,6 +1,6 @@ /* strtol - convert string representation of a number into a long integer value. */ -/* Copyright (C) 1991-2001,2022 Free Software Foundation, Inc. +/* Copyright (C) 1991-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -42,10 +42,6 @@ extern int errno; #include #include -#ifndef NULL -# define NULL 0 -#endif - /* Nonzero if we are defining `strtoul' or `strtoull', operating on unsigned integers. */ #ifndef UNSIGNED diff --git a/parse.y b/parse.y index 3e28d24d..368c3423 100644 --- a/parse.y +++ b/parse.y @@ -4497,6 +4497,8 @@ parse_comsub (int qc, int open, int close, size_t *lenp, int flags) /* yyparse() has already called yyerror() and reset_parser(), so we set PST_NOERROR to avoid a redundant error message. */ parser_state |= PST_NOERROR; + + flush_parser_state (&ps); return (&matched_pair_error); } else if (r != 0) @@ -4513,6 +4515,7 @@ parse_comsub (int qc, int open, int close, size_t *lenp, int flags) shell_eof_token = ps.eof_token; expand_aliases = ps.expand_aliases; + flush_parser_state (&ps); jump_to_top_level (DISCARD); /* XXX - return (&matched_pair_error)? */ } } @@ -4529,6 +4532,7 @@ INTERNAL_DEBUG(("current_token (%d) != shell_eof_token (%c)", current_token, she shell_eof_token = ps.eof_token; expand_aliases = ps.expand_aliases; + flush_parser_state (&ps); return (&matched_pair_error); } @@ -7191,6 +7195,27 @@ restore_parser_state (sh_parser_state_t *ps) shell_eof_token = ps->eof_token; } +/* Free the parts of a parser state struct that have allocated memory. */ +void +flush_parser_state (sh_parser_state_t *ps) +{ + if (ps == 0) + return; + + FREE (ps->token_state); + ps->token_state = 0; + + if (ps->pipestatus) + array_dispose (ps->pipestatus); + ps->pipestatus = 0; + + /* We want to free the saved token and leave the current token for error + reporting and cleanup. */ + FREE (ps->token); + ps->token = 0; + ps->token_buffer_size = 0; +} + sh_input_line_state_t * save_input_line_state (sh_input_line_state_t *ls) { diff --git a/po/de.gmo b/po/de.gmo index fbf52b3d98ebe24a361df29dbd729e4cefd88f03..9a5fe86364611da7f93a37062814ad3a4e961ef5 100644 GIT binary patch delta 19107 zcmb7~349erwuk#h1w|N3z2PndaB0R7+)*bg z>Zquw&kbZm5rr9*;HcoPqbRPpppK#=J~vd}_wVW(5(xOFf4|CCRb6%J)TvXat1i5} zuhE|M$Gh*HbnJB&Pwy1V>Ie&4Sk_16ALy!D%Nm+)S$*IzcoHmxBVi@%4j+b%;ajj7 z{1`TX`{2p&XV?n1>u*_|VLEIBr^D8k-VIy8x1kNcggqGFYRcOla1dlt)_k9r zLri3C_W26Ln${jDi?kVJ1|AHh;5^tDMxX}zD{KqbLe2c2PzvpaEul3S`%CjyWK?k~ zJP}TTYIp`z$EC0}ydJ9k15k>-pCX?1wgNH`KDa zz~NAeoiP;qOOq%S{ooZ)f*yl5d>(3muV7Pn>@ds1U96L!mSP-~g`$4_N~noE0j0qE zQ1bRcIcWnNOXW6Da(laEr14nT4$gyZVHCE9mqQJFH`GiXh8o~iD4+QjY9{UQV7>1T zRi5Uv0LpSppe(lrHiKKC`n#`?8A#?ws5R=x=I#I|K`ns;Pk>9II;?=lz_n0I_c!PX zgi`bssF}SFnY8si>;?ynGWD~eoU;@n*R{?k^9d3!g%e>U%b03Yj^VRV3hadA0|XeT z0sD?O?}x)ClqW;An+p|B3VfEspN}J8K`lviDm#jZwE{NM{?DFkS!`u%3M^-U^P$%2 z-}6{U%KKqz3Y|_Ts8D|G43t69j5953Hua73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Ut}Jv>8rmZ0M%dFzlbU^9StAL4OX zm5@&SAsnE)x0C2ZxK7Y9i*O}~@qd(XQ3M54BfXYz4{05GSHI@sO20$=LENE)JGztC z+FcXwd=5_&+H*}ZVU2be9be-)!dHZaHp|5E;Ma*?A`B!H=bSzQqRH3Mob(*5ss!=j z1RaO*Wx{=g_X%|fQQY%0KF0Zv3HX)c$5n_kT`-m;<2@j z2LI-{_)7Bsaq$@9DFi-rgE!tN;<1GJoX@~N@prtYExQtt5rk4)+yOH=`HCyZBdyP! zT?ExLjdW$gCPE|9NAX_N(S`UW!el~1&haWq{=fEwx#4^lb2+P{G-hFhOCJt$`S`{+ zU0y-rKN2E&^i%Hq+wR;Sq(kHvR<+!55|?qlkj-ly{0ETnWX>k@Rm|^h*7f)4AC3aTU=LrK{DNi~l;5fo@m+s{}#kD%R66UzPy4cypb*>5V1vrYZlX!J( zfQtx2iOj_!J_YsQFuXp1S^4``-jza|g zf)X4B-90vC|NVr#UtLBGe3x`FoUHb*B*bttzk6}>RGCC6fg}{$fa|53t z|3CN`;m(mr{Am&&xQq|ox$0Pw`*d6-3?cnEwshyeAU=$sV-X>Sa5VVOi$of2$V_ij sWy6JD-79UlIqmhg3T9*^*UD&Ed-IYS-mzMnle4|@)i(dS*z>pi5AJPjqyPW_ diff --git a/po/de.po b/po/de.po index 5070d8be..5292ac00 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: bash 5.2-rc1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-01-11 14:50-0500\n" -"PO-Revision-Date: 2024-03-11 21:33+0100\n" +"PO-Revision-Date: 2024-03-24 13:13+0100\n" "Last-Translator: Nils Naumann \n" "Language-Team: German \n" "Language: de\n" @@ -4326,7 +4326,6 @@ msgstr "" # test #: builtins.c:1262 -#, fuzzy msgid "" "Evaluate conditional expression.\n" " \n" @@ -4408,13 +4407,13 @@ msgid "" msgstr "" "Bedingten Ausdruck auswerten.\n" " \n" -" Wird Status 0 (wahr) oder 1 (falsch) abhängig vom Ergebnis des\n" -" Ausdrucks. Die Ausdrücke können unär oder binär sein. Unäre\n" +" Gibt den Status 0 (wahr) oder 1 (falsch) abhängig vom Ergebnis des\n" +" Ausdrucks zurück. Die Ausdrücke können unär oder binär sein. Unäre\n" " Ausdrücke werden häufig verwendet, um den Dateistatus zu ermitteln.\n" " Es gibt weiterhin Zeichenketten und numerische Vergeichsoperatoren.\n" " \n" -" Das Verhalten von test hängt von der Argumentanzahl ab. Die\n" -" bash Handbuchseite enthält deren vollständige Beschreibung.\n" +" Das Verhalten hängt von der Argumentanzahl ab. Die bash\n" +" Handbuchseite enthält deren vollständige Beschreibung.\n" " \n" " Dateioperatoren:\n" " \n" @@ -4432,7 +4431,7 @@ msgstr "" " -r Datei Wahr, wenn die Datei für den aktuellen Nutzer lesbar ist.\n" " -s Datei Wahr, wenn die Datei existiert und nicht leer ist.\n" " -S Datei Wahr, wenn die Datei ein Socket ist.\n" -" -t FD Wahr, wenn FD auf einem Terminal geöffnet ist.\n" +" -t FD Wahr, wenn FD auf einem Terminal geöffnet ist.\n" " -u Datei Wahr, wenn das SetUID-Bit der Datei gesetzt ist.\n" " -w Datei Wahr, wenn die Datei für den aktuellen Nutzer schreibbar ist.\n" " -x Datei Wahr, wenn die Datei vom aktuellen Nutzer ausführbar ist.\n" @@ -4441,23 +4440,23 @@ msgstr "" " -N Datei Wahr, wenn die Datei seit dem letzten Lesen geändert wurde.\n" " \n" " Datei1 -nt Datei2 Wahr, wenn Datei1 neuer als Datei2 ist (gemäß\n" -" Änderungsdatum).\n" +" Änderungsdatum).\n" " \n" " Datei1 -ot Datei2 Wahr, wenn Datei1 älter als Datei2 ist.\n" " \n" " Datei1 -ef Datei2 Wahr, wenn Datei1 ein harter Link zu Datei2 ist.\n" " \n" -" Zeichenfolgenoperatoren:\n" +" Zeichenkettenoperatoren:\n" " \n" -" -z STRING Wahr, wenn die Zeichenfolge leer ist.\n" +" -z STRING Wahr, wenn die Zeichenkette leer ist.\n" " \n" " -n STRING\n" -" STRING Wahr, wenn die Zeichenfolge nicht leer ist.\n" +" STRING Wahr, wenn die Zeichenkette nicht leer ist.\n" " \n" " STRING1 = STRING2\n" -" Wahr, wenn die Zeichenfolgen gleich sind.\n" +" Wahr, wenn die Zeichenketten gleich sind.\n" " STRING1 != STRING2\n" -" Wahr, wenn die Zeichenfolgen nicht gleich sind.\n" +" Wahr, wenn die Zeichenketten nicht gleich sind.\n" " STRING1 < STRING2\n" " Wahr, wenn STRING1 lexikografisch vor STRING2\n" " sortiert wird.\n" @@ -4468,9 +4467,9 @@ msgstr "" " Andere Operatoren:\n" " \n" " -o OPTION Wahr, wenn die Shell-Option OPTION aktiviert ist.\n" -" -v VAR Wahr, wenn die Shell-Variable VAR gesetzt ist.\n" -" -R VAR Wahr, wenn die Variable gesetzt ist und ein Nameref ist.\n" -" ! EXPR Wahr, wenn Ausdruck falsch ist.\n" +" -v VAR Wahr, wenn die Shell-Variable VAR gesetzt ist.\n" +" -R VAR Wahr, wenn die Variable gesetzt ist und ein Nameref ist.\n" +" ! EXPR Wahr, wenn Ausdruck falsch ist.\n" " EXPR1 -a EXPR2 Wahr, wenn sowohl expr1 als auch expr2 wahr sind.\n" " EXPR1 -o EXPR2 Wahr, wenn entweder expr1 ODER expr2 wahr ist.\n" " \n" @@ -4830,6 +4829,7 @@ msgid "" " Returns the status of the last command executed." msgstr "" +# coproc #: builtins.c:1672 msgid "" "Create a coprocess named NAME.\n" @@ -4842,6 +4842,16 @@ msgid "" " Exit Status:\n" " The coproc command returns an exit status of 0." msgstr "" +"Startet einen Koprozess mit dem angegebenen Namen.\n" +" \n" +" Führt das angegebene Kommando asynchron in einem Kindprozess aus.\n" +" Deren Standardaus- und -eingabe werden mit jeweils einer Pipe\n" +" verbunden. Deren Dateideskriptoren sind in den Indexen 0 und 1 der\n" +" Feldvariable mit dem angegebenen Namen verknüpft.\n" +" Der Standardname ist „COPROC“.\n" +" \n" +" Rückgabewert:\n" +" Der Befehl gibt immer 0 zurück." # function #: builtins.c:1686 diff --git a/shell.h b/shell.h index 61673726..5a18f405 100644 --- a/shell.h +++ b/shell.h @@ -1,6 +1,6 @@ /* shell.h -- The data structures used by the shell */ -/* Copyright (C) 1993-2023 Free Software Foundation, Inc. +/* Copyright (C) 1993-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -239,6 +239,7 @@ extern char *parser_remaining_input (void); extern sh_parser_state_t *save_parser_state (sh_parser_state_t *); extern void restore_parser_state (sh_parser_state_t *); +extern void flush_parser_state (sh_parser_state_t *); extern sh_input_line_state_t *save_input_line_state (sh_input_line_state_t *); extern void restore_input_line_state (sh_input_line_state_t *); diff --git a/test.c b/test.c index 09dc1478..467f8ea0 100644 --- a/test.c +++ b/test.c @@ -267,15 +267,23 @@ term (void) /* A paren-bracketed argument. */ if (argv[pos][0] == '(' && argv[pos][1] == '\0') /* ) */ { - int nargs; + int nargs, count; advance (1); /* Steal an idea from coreutils and scan forward to check where the right paren appears to prevent some ambiguity. If we find a valid sub- - expression that has 1-4 arguments, call posixtest on it ( */ - for (nargs = 1; pos + nargs < argc && ISTOKEN (argv[pos+nargs], ')') == 0; nargs++) - ; - /* only do this if we have a valid parenthesized expression */ + expression that has 1-4 arguments, call posixtest on it. Handle + nested subexpressions. ( */ + for (nargs = count = 1; pos + nargs < argc; nargs++) + { + if (ISTOKEN (argv[pos+nargs], ')')) + count--; + else if (ISTOKEN (argv[pos+nargs], '(')) /*)*/ + count++; + if (count == 0) + break; + } + /* only use posixtest if we have a valid parenthesized expression */ value = (pos + nargs < argc && nargs <= 4) ? posixtest (nargs) : expr (); if (argv[pos] == 0) /* ( */ test_syntax_error (_("`)' expected"), (char *)NULL); diff --git a/unwind_prot.c b/unwind_prot.c index da9218ba..4a5195a6 100644 --- a/unwind_prot.c +++ b/unwind_prot.c @@ -3,7 +3,7 @@ /* I can't stand it anymore! Please can't we just write the whole Unix system in lisp or something? */ -/* Copyright (C) 1987-2023 Free Software Foundation, Inc. +/* Copyright (C) 1987-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -35,14 +35,6 @@ # include #endif -#if defined (HAVE_STDDEF_H) -# include -#endif - -#ifndef offsetof -# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - #include "command.h" #include "general.h" #include "unwind_prot.h" diff --git a/xmalloc.c b/xmalloc.c index 3777d53d..05de3874 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -29,11 +29,8 @@ # include #endif -#if defined (HAVE_STDLIB_H) -# include -#else -# include "ansi_stdlib.h" -#endif /* HAVE_STDLIB_H */ +#include "bashansi.h" +#include #include "error.h" @@ -131,6 +128,22 @@ xrealloc (PTR_T pointer, size_t bytes) return (temp); } +/* Reallocate the storage addressed by POINTER so that it is of + size NMEMB*SIZE, preserving contents like realloc does. + If POINTER is null, allocate new storage. This is like + glibc reallocarray except that it never returns a null pointer; + if storage is exhausted it reports an error and exits. */ +PTR_T +xreallocarray (PTR_T ptr, size_t nmemb, size_t size) +{ + size_t nbytes; + + if (ckd_mul (&nbytes, nmemb, size)) + allocerr ("xreallocarray", (size_t)-1); + + return xrealloc (ptr, nbytes); +} + /* Use this as the function to call when adding unwind protects so we don't need to know what free() returns. */ void @@ -192,6 +205,17 @@ sh_xrealloc (PTR_T pointer, size_t bytes, char *file, int line) return (temp); } +PTR_T +sh_xreallocarray (PTR_T ptr, size_t nmemb, size_t size, const char *file, int line) +{ + size_t nbytes; + + if (ckd_mul (&nbytes, nmemb, size)) + sh_allocerr ("xreallocarray", (size_t)-1, file, line); + + return sh_xrealloc (ptr, nbytes, file, line); +} + void sh_xfree (PTR_T string, char *file, int line) { diff --git a/xmalloc.h b/xmalloc.h index d8731305..d8fb32a7 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -1,6 +1,6 @@ /* xmalloc.h -- defines for the `x' memory allocation functions */ -/* Copyright (C) 2001-2023 Free Software Foundation, Inc. +/* Copyright (C) 2001-2024 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -32,15 +32,18 @@ /* Allocation functions in xmalloc.c */ extern PTR_T xmalloc (size_t); extern PTR_T xrealloc (void *, size_t); +extern PTR_T xreallocarray (void *, size_t, size_t); extern void xfree (void *); #if defined(USING_BASH_MALLOC) && !defined (DISABLE_MALLOC_WRAPPERS) extern PTR_T sh_xmalloc (size_t, const char *, int); extern PTR_T sh_xrealloc (void *, size_t, const char *, int); +extern PTR_T sh_xreallocarray (void *, size_t, size_t, const char *, int); extern void sh_xfree (void *, const char *, int); #define xmalloc(x) sh_xmalloc((x), __FILE__, __LINE__) #define xrealloc(x, n) sh_xrealloc((x), (n), __FILE__, __LINE__) +#define xreallocarray(x, n, s) sh_xreallocarray((x), (n), (s), __FILE__, __LINE__) #define xfree(x) sh_xfree((x), __FILE__, __LINE__) #ifdef free