[PATCH] use EVRP in more strlen functions

Martin Sebor msebor@gmail.com
Mon Oct 28 22:44:00 GMT 2019


While testing the patch for PR 92226 I posted earlier today
I ran into a few cases where I expected the strlen range
optimization to take place but it didn't.

In other instances this wouldn't be surprising because
the optimization was only introduced for multi-character stores
and with the expectation that it would be slowly extended to
other functions over time.  But these cases were among those
the optimization was meant to be in place for, so its absence
is an oversight.  The attached near-trivial patch fills this
gap.

As with all these changes, enabling the optimization also makes
it possible to detect more instances of buffer overflow.

Tested on x86_64-linux.

Martin

PS There are quite a few remaining opportunities to make use of
the strlen ranges in the pass.  Rather than enhancing the whole
pass in one go I think it will be safer to do it one small step
at a time, using little patchlets like in the attachment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-92226-2.diff
Type: text/x-patch
Size: 8821 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191028/095f4580/attachment.bin>


More information about the Gcc-patches mailing list