Mercurial > gnulib
changeset 38901:ead4e3bf6c56
quotearg: pacify compiler re unsigned
* lib/quotearg.c (quotearg_n_options):
Rewrite to avoid diagnostic from overly-picky compiler.
Problem reported by Sami Kerola in:
https://lists.gnu.org/archive/html/bug-gnulib/2017-10/msg00060.html
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 19 Oct 2017 13:03:40 -0700 |
parents | 63c578da3f18 |
children | 78a7785c42b9 |
files | ChangeLog lib/quotearg.c |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Oct 19 12:39:45 2017 -0700 +++ b/ChangeLog Thu Oct 19 13:03:40 2017 -0700 @@ -1,5 +1,11 @@ 2017-10-19 Paul Eggert <eggert@cs.ucla.edu> + quotearg: pacify compiler re unsigned + * lib/quotearg.c (quotearg_n_options): + Rewrite to avoid diagnostic from overly-picky compiler. + Problem reported by Sami Kerola in: + https://lists.gnu.org/archive/html/bug-gnulib/2017-10/msg00060.html + glob: fix heap buffer overflow * lib/glob.c (glob): Fix off-by-one error introduced into glibc in commit dd7d45e838a42b0ed470c44b55901ea98d0c2bab
--- a/lib/quotearg.c Thu Oct 19 12:39:45 2017 -0700 +++ b/lib/quotearg.c Thu Oct 19 13:03:40 2017 -0700 @@ -887,8 +887,9 @@ if (nslots <= n) { bool preallocated = (sv == &slotvec0); + int nmax = MIN (INT_MAX, MIN (PTRDIFF_MAX, SIZE_MAX) / sizeof *sv) - 1; - if (MIN (INT_MAX, MIN (PTRDIFF_MAX, SIZE_MAX) / sizeof *sv) <= n) + if (nmax < n) xalloc_die (); slotvec = sv = xrealloc (preallocated ? NULL : sv, (n + 1) * sizeof *sv);