Message ID | 543F83FB.9000408@samsung.com |
---|---|
State | New |
Headers | show |
On Thu, Oct 16, 2014 at 12:38:19PM +0400, Yury Gribov wrote: > Same as mainline. > 2014-10-15 Yury Gribov <y.gribov@samsung.com> > > Backport from mainline > 2014-06-18 Yury Gribov <y.gribov@samsung.com> > > PR sanitizer/61530 > > * asan.c (build_check_stmt): Add condition. > > * c-c++-common/asan/pr61530.c: New test. Ok. Note, for the patches that fix bugs in earlier patches, please commit them in one svn revision together with the patch that caused the bugs, so that 4.9 isn't broken unnecessarily. Jakub
2014-10-15 Yury Gribov <y.gribov@samsung.com> Backport from mainline 2014-06-18 Yury Gribov <y.gribov@samsung.com> PR sanitizer/61530 * asan.c (build_check_stmt): Add condition. * c-c++-common/asan/pr61530.c: New test. diff --git a/gcc/asan.c b/gcc/asan.c index 3729178..c838423 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1653,6 +1653,7 @@ build_check_stmt (location_t location, tree base, tree len, if (size_in_bytes > 1) { if ((size_in_bytes & (size_in_bytes - 1)) != 0 + || !is_scalar_access || size_in_bytes > 16) size_in_bytes = -1; else if (align && align < size_in_bytes * BITS_PER_UNIT) diff --git a/gcc/testsuite/c-c++-common/asan/pr61530.c b/gcc/testsuite/c-c++-common/asan/pr61530.c new file mode 100644 index 0000000..e306a71 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr61530.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-shouldfail "asan" } */ + +__attribute__((noinline,noclone)) void +foo (char *a, char *b) { + a[0] = b[0] = 0; + __builtin_memcpy(a, b, 4); +} + +int +main () { + char a, b; + foo (&a, &b); + return 0; +} + +/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */