This is the mail archive of the
gcc-patches@gcc.gnu.org
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: <a0d277c4-41c5-61a8-0284-5b1b245e2c74@gmail.com> <ff946355-efec-e286-d7b7-1505a8acc55b@gmail.com> <fcafd5f3-b8fa-faa3-29f4-41fab9d927c8@gmail.com> <e5a3824c-5735-c1f4-3a07-e09f7205a9a6@gmail.com>
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