[PATCH 1/5] argp: fix pointer-subtraction bug

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Feb 2 14:30:11 GMT 2021



On 06/01/2021 22:06, Bruno Haible wrote:
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> * 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

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  argp/argp-help.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/argp/argp-help.c b/argp/argp-help.c
> index 15c5fd2..f417e12 100644
> --- a/argp/argp-help.c
> +++ b/argp/argp-help.c
> @@ -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.  */
> 


More information about the Libc-alpha mailing list