On 08/13/2018 03:27 PM, Martin Sebor wrote:
> The attached changes implement the detection of past-the-end reads
> by strcpy due to unterminated arguments.
> 
> gcc-86552-3.diff
> 
> 
> PR tree-optimization/86552 - missing warning for reading past the end of 
> non-string arrays
> 
> gcc/ChangeLog:
> 
>       * builtins.c (unterminated_array): New.
>       (expand_builtin_strcpy): Adjust.
>       (expand_builtin_strcpy_args): Detect unterminated arrays.
>       * gimple-fold.c (get_maxval_strlen): Add argument.  Detect
>       unterminated arrays.
>       * gimple-fold.h (get_maxval_strlen): Add argument.
>       (gimple_fold_builtin_strcpy): Detec unterminated arrays.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.dg/warn-strcpy-no-nul.c: New test.
>From a review standpoint this is essentially in the same state as patch
#2.  It depends on bits that haven't been installed (yet) and needs
trivial API updates.  There's one test that is an XPASS which is clearly
a derived from the same test that is an XPASS in patch #2.


While reviewing I noticed that get_maxval_strlen didn't have a function
comment.  So I added one.  get_maxval_strlen will likely need further
refinement of its comment or code once get_range_strlen gets revamped.

As with patch #2 in this series, I'll own posting the final patch and
committing the bits.

jeff

Reply via email to