Cherry-pick upstream r299036 from libsanitizer (PR sanitizer/80166).

2017-04-06  Martin Liska  <mliska@suse.cz>

	PR sanitizer/80166
	* sanitizer_common/sanitizer_common_interceptors.inc (INTERCEPTOR):
	Cherry-pick upstream r299036.
2017-04-06  Martin Liska  <mliska@suse.cz>

	PR sanitizer/80166
	* gcc.dg/asan/pr80166.c: New test.

From-SVN: r246730
This commit is contained in:
Martin Liska 2017-04-06 15:42:24 +02:00 committed by Martin Liska
parent 1b68991f4d
commit d9f8c5af8b
4 changed files with 37 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2017-04-06 Martin Liska <mliska@suse.cz>
PR sanitizer/80166
* gcc.dg/asan/pr80166.c: New test.
2017-04-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR tree-optimization/79390

View File

@ -0,0 +1,24 @@
/* PR sanitizer/80166 */
/* { dg-do run } */
#include <sys/types.h>
#include <unistd.h>
int
main (int argc, char **argv)
{
gid_t groups;
int r = getgroups (0, &groups);
if (r < 0)
__builtin_abort ();
r = getgroups (-1, &groups);
if (r != -1)
__builtin_abort ();
r = getgroups (-1, NULL);
if (r != -1)
__builtin_abort ();
return 0;
}

View File

@ -1,3 +1,9 @@
2017-04-06 Martin Liska <mliska@suse.cz>
PR sanitizer/80166
* sanitizer_common/sanitizer_common_interceptors.inc (INTERCEPTOR):
Cherry-pick upstream r299036.
2017-03-22 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/78158

View File

@ -3350,7 +3350,8 @@ INTERCEPTOR(int, getgroups, int size, u32 *lst) {
// its metadata. See
// https://github.com/google/sanitizers/issues/321.
int res = REAL(getgroups)(size, lst);
if (res && lst) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, lst, res * sizeof(*lst));
if (res >= 0 && lst && size > 0)
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, lst, res * sizeof(*lst));
return res;
}
#define INIT_GETGROUPS COMMON_INTERCEPT_FUNCTION(getgroups);