This is the mail archive of the gcc-patches@gcc.gnu.org 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 5/6] detect unterminated const arrays in stpcpy calls (PR 86552)


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


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