[PATCH] extend missing nul checks to all built-ins (PR 88226)

Martin Sebor msebor@gmail.com
Thu Nov 14 17:42:00 GMT 2019


GCC 9 added checks for usafe uses of unterminated constant char
arrays to a few string functions but the checking is far from
comprehensive.  It's been on my list of things to do to do
a more thorough review and add the checks where they're missing.

The attached patch does this for the majority of common built-ins.
There still are a few where it could be added but this should cover
most of the commonly used ones where the misuses are likely to come
up.

This patch depends on the one I posted earlier today for PR 92501:
   https://gcc.gnu.org/ml/gcc-patches/2019-11/msg01233.html

I tested both patches together on x86_64-linux.

Martin

PS I considered introducing a new attribute, say string, first
to reduce the extent of the changes in GCC, and second to provide
a mechanism to let GCC check even user-defined functions for these
bugs.  I stopped short of doing this because most of the changes
to the built-ins are necessary either way, and also because it
seems late in the cycle to introduce such an extension.  Unless
there's a strong preference for adding it now I will revisit
the decision for GCC 11.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-88226.diff
Type: text/x-patch
Size: 40462 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191114/4565f6b1/attachment.bin>


More information about the Gcc-patches mailing list