This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/6] detect unterminated const arrays in strcpy calls (PR 86552)

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]