This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH 3/6] detect unterminated const arrays in strcpy calls (PR 86552)
- From: Jeff Law <law at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 30 Aug 2018 16:30:34 -0600
- Subject: Re: [PATCH 3/6] detect unterminated const arrays in strcpy calls (PR 86552)
- References: <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org>
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.
> PR tree-optimization/86552 - missing warning for reading past the end of non-string arrays
> * 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.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.