History log of /bionic/libc/string/__strcat_chk.c
Revision Date Author Comments
009f38478e6a1c47aa355b0aed80b69ba91b9c61 08-Jun-2012 Geremy Condra <gcondra@google.com> Added actual event logging calls to the FORTIFY_SOURCE methods.

Change-Id: I3bf4fa8678c33187cb8ce4b75e666ddcd24403ab
76656afc6dd069fcfda5768e6e54bb85e4e99942 08-Jun-2012 Nick Kralevich <nnk@google.com> _FORTIFY_SOURCE: check for integer overflows

Ensure that strcat / strncat check for integer overflows
when computing the length of the resulting string.

Change-Id: Ib806ad33a0d3b50876f384bc17787a28f0dddc37
0a2301598c207fd1b50015984942fee5e8511593 05-Jun-2012 Nick Kralevich <nnk@google.com> libc: implement some FORTIFY_SOURCE functions

Add initial support for -D_FORTIFY_SOURCE to bionic for the
following functions:

* memcpy
* memmove
* strcpy
* strcat
* strncpy
* strncat

This change adds a new version of the above functions which passes
the size of the destination buffer to __builtin___*_chk.

If the compiler can determine, at compile time, that the destination
buffer is large enough, or the destination buffer can point to an object
of unknown size, then the check call is bypassed.

If the compiler can't make a compile time decision, then it calls
the __*_chk() function, which does a runtime buffer size check

These options are only enabled if the code is compiled with
-D_FORTIFY_SOURCE=1 or 2, and only when optimizations are enabled.

Please see
* http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
* http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html

for additional details on FORTIFY_SOURCE.

Testing: Compiled the entire Android tree with -D_FORTIFY_SOURCE=1,
and verified that everything appears to be working properly.
Also created a test buffer overflow, and verified that it was
caught by this change.

Change-Id: I4fddb445bafe92b16845b22458d72e6dedd24fbc