This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 5/6] detect unterminated const arrays in stpcpy 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: Fri, 14 Sep 2018 12:29:38 -0600
- Subject: Re: [PATCH 5/6] detect unterminated const arrays in stpcpy 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> <267b54f8-c0c5-0205-d792-747a11567ff6@gmail.com>
On 8/13/18 3:28 PM, Martin Sebor wrote:
> The attached changes implement the detection of past-the-end reads
> by stpcpy due to unterminated arguments.
>
>
> gcc-86552-5.diff
>
> PR tree-optimization/86552 - missing warning for reading past the end of non-string arrays
>
> gcc/ChangeLog:
>
> * builtins.c (unterminated_array): Handle ARRAY_REF.
> (expand_builtin_stpcpy_1): Detect unterminated char arrays.
> * builtins.h (unterminated_array): Declare extern.
> * gimple-fold.c (gimple_fold_builtin_stpcpy): Detect unterminated
> arrays.
> (gimple_fold_builtin_sprintf): Propagate NO_WARNING to transformed
> calls.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/warn-stpcpy-no-nul.c: New test.
So with this patch I just added initialization for a NONSTR passed down
to c_strlen. Otherwise it just worked on top of all the recent changes.
I'll install it on the trunk momentarily.
I'll probably stop here today to let the testers run through another
cycle. What's left of this kit is #4 (sprintf) and #6 (strnlen).
Jeff