]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
argp: fix pointer-subtraction bug
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 Jan 2021 01:06:16 +0000 (02:06 +0100)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 4 Feb 2021 19:44:20 +0000 (16:44 -0300)
* argp/argp-help.c (hol_append): Don't subtract pointers to
different arrays, as this can run afoul of -fcheck-pointer-bounds.
See the thread containing Bruno Haible's report in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00171.html

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
argp/argp-help.c

index 15c5fd237b1e869922270b09d7f6fea75a8b133e..f417e1294c08609a464f2fa13f9de4ee10e6a1c3 100644 (file)
@@ -867,7 +867,8 @@ hol_append (struct hol *hol, struct hol *more)
 
          /* Fix up the short options pointers from HOL.  */
          for (e = entries, left = hol->num_entries; left > 0; e++, left--)
-           e->short_options += (short_options - hol->short_options);
+           e->short_options
+             = short_options + (e->short_options - hol->short_options);
 
          /* Now add the short options from MORE, fixing up its entries
             too.  */