aboutsummaryrefslogtreecommitdiffstats
path: root/libc/docs
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2012-07-12 15:10:03 -0700
committerNick Kralevich <nnk@google.com>2012-07-12 15:38:15 -0700
commitf3913b5b68347ce9a4cb17977df2c33f1e8f6000 (patch)
treefae959e2f8c146b61eb43af80d9ae4918640d2c0 /libc/docs
parent86a4fca0b473c49bcbcf2deb6b5822aa9ab9631e (diff)
downloadandroid_bionic-f3913b5b68347ce9a4cb17977df2c33f1e8f6000.tar.gz
android_bionic-f3913b5b68347ce9a4cb17977df2c33f1e8f6000.tar.bz2
android_bionic-f3913b5b68347ce9a4cb17977df2c33f1e8f6000.zip
FORTIFY_SOURCE: enhanced memcpy protections.
Two changes: 1) Detect memory read overruns. For example: int main() { char buf[10]; memcpy(buf, "abcde", sizeof(buf)); sprintf("%s\n", buf); } because "abcde" is only 6 bytes, copying 10 bytes from it is a bug. This particular bug will be detected at compile time. Other similar bugs may be detected at runtime. 2) Detect overlapping buffers on memcpy() It is a bug to call memcpy() on buffers which overlap. For example, the following code is buggy: char buf3[0x800]; char *first_half = &buf3[0x400]; char *second_half = &buf3[1]; memset(buf3, 0, sizeof(buf3)); memcpy(first_half, second_half, 0x400); printf("1: %s\n", buf3); We now detect this at compile and run time. Change-Id: I092bd89f11f18e08e8a9dda0ca903aaea8e06d91
Diffstat (limited to 'libc/docs')
0 files changed, 0 insertions, 0 deletions