platform_bionic/libc/string
Nick Kralevich f3913b5b68 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
2012-07-12 15:38:15 -07:00
..
__memcpy_chk.c FORTIFY_SOURCE: enhanced memcpy protections. 2012-07-12 15:38:15 -07:00
__memmove_chk.c Added actual event logging calls to the FORTIFY_SOURCE methods. 2012-06-11 11:30:56 -07:00
__memset_chk.c Added actual event logging calls to the FORTIFY_SOURCE methods. 2012-06-11 11:30:56 -07:00
__strcat_chk.c Added actual event logging calls to the FORTIFY_SOURCE methods. 2012-06-11 11:30:56 -07:00
__strcpy_chk.c Added actual event logging calls to the FORTIFY_SOURCE methods. 2012-06-11 11:30:56 -07:00
__strlcat_chk.c FORTIFY_SOURCE: add strlcpy / strlcat support 2012-06-14 12:52:42 -07:00
__strlcpy_chk.c FORTIFY_SOURCE: add strlcpy / strlcat support 2012-06-14 12:52:42 -07:00
__strncat_chk.c Added actual event logging calls to the FORTIFY_SOURCE methods. 2012-06-11 11:30:56 -07:00
__strncpy_chk.c Added actual event logging calls to the FORTIFY_SOURCE methods. 2012-06-11 11:30:56 -07:00
bcopy.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
index.c string: Fix wrong comparison semantics 2011-12-05 18:37:10 -08:00
memccpy.c Fix return value. 2010-08-31 15:19:38 -07:00
memchr.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
memcmp.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
memcpy.c Generic memcpy should define MEMCOPY before including bcopy.c 2010-02-05 15:13:55 -08:00
memmem.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
memmove.c FORTIFY_SOURCE: enhanced memcpy protections. 2012-07-12 15:38:15 -07:00
memrchr.c string: Fix wrong comparison semantics 2011-12-05 18:37:10 -08:00
memset.c Correct generic memset implementation 2010-02-05 15:13:55 -08:00
memswap.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strcasecmp.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strcasestr.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strcat.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strchr.c string: Fix wrong comparison semantics 2011-12-05 18:37:10 -08:00
strcmp.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strcoll.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strcpy.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strcspn.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strdup.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strerror.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strerror_r.c Fix strerror(3) for errno 0. 2011-05-13 10:54:34 -07:00
strlcat.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strlcpy.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strlen.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strncat.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strncmp.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strncpy.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strndup.c string: tidy up strndup() 2010-01-30 22:29:59 -02:00
strnlen.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strpbrk.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strrchr.c string: Fix wrong comparison semantics 2011-12-05 18:37:10 -08:00
strsep.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strspn.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strstr.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00
strtok.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strtotimeval.c auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
strxfrm.c improve readability of string: fix indentation and remove trailing spaces 2010-01-30 22:28:49 -02:00