On 08/22/2018 08:41 AM, Bernd Edlinger wrote:
> Hi!
> 
> 
> This patch adds some more checks to c_getstr to fix PR middle-end/87053
> wrong code bug.
> 
> Unfortunately this patch alone is not sufficient to fix the problem,
> but also the patch for PR 86714 that hardens c_getstr is necessary
> to prevent the wrong folding.
> 
> 
> Bootstrapped and reg-tested on top of my PR 86711/86714 patch.
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.
> 
> 
> 
> patch-pr87053.diff
> 
> 
> gcc:
> 2018-08-22  Bernd Edlinger  <bernd.edlin...@hotmail.de>
> 
>       PR middle-end/87053
>       * builtins.c (c_strlen): Improve range checks.
> 
> testsuite:
> 2018-08-22  Bernd Edlinger  <bernd.edlin...@hotmail.de>
> 
>       PR middle-end/87053
>       * gcc.c-torture/execute/pr87053.c: New test.
This is OK and I'm going to go ahead and commit it momentarily.


>> @@ -700,6 +700,10 @@ c_strlen (tree src, int only_value, unsi
>    unsigned len = string_length (ptr + eltoff * eltsize, eltsize,
>                               strelts - eltoff);
>  
> +  /* Don't know what to return if there was no zero termination.  */
> +  if (len > maxelts - eltoff)
> +    return NULL_TREE;
> +
I'm going to add a comment to the code above indicating that it'd be
nice if this could be an assert in the future.  We're not there yet.

Jeff

Reply via email to