public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH] Cherry-pick upstream r299036 from libsanitizer (PR sanitizer/80166).
Date: Fri, 31 Mar 2017 08:34:00 -0000	[thread overview]
Message-ID: <70b7d075-a235-b4d8-759f-b676b32d08a2@suse.cz> (raw)

[-- Attachment #1: Type: text/plain, Size: 145 bytes --]

Hello.

Cherry-picking the commit to fix PR reported originally to the GCC.
Ready to install after it finishes regression tests?

Thanks,
Martin

[-- Attachment #2: 0001-Cherry-pick-upstream-r299036-from-libsanitizer-PR-sa.patch --]
[-- Type: text/x-patch, Size: 2146 bytes --]

From 36cc9827dd47f213bb17dd7e37b3b19b740a0928 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 31 Mar 2017 10:28:25 +0200
Subject: [PATCH] Cherry-pick upstream r299036 from libsanitizer (PR
 sanitizer/80166).

libsanitizer/ChangeLog:

2017-03-31  Martin Liska  <mliska@suse.cz>

	* sanitizer_common/sanitizer_common_interceptors.inc (INTERCEPTOR):
	Cherry-pick upstream r299036.

gcc/testsuite/ChangeLog:

2017-03-31  Martin Liska  <mliska@suse.cz>

	* gcc.dg/asan/pr80166.c: New test.
---
 gcc/testsuite/gcc.dg/asan/pr80166.c                | 24 ++++++++++++++++++++++
 .../sanitizer_common_interceptors.inc              |  3 ++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/asan/pr80166.c

diff --git a/gcc/testsuite/gcc.dg/asan/pr80166.c b/gcc/testsuite/gcc.dg/asan/pr80166.c
new file mode 100644
index 00000000000..629dd23a31c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr80166.c
@@ -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;
+}
diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
index 0970eda5ee6..195014022a0 100644
--- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
@@ -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);
-- 
2.12.0


             reply	other threads:[~2017-03-31  8:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-31  8:34 Martin Liška [this message]
2017-04-06 12:53 ` Martin Liška
2017-04-06 12:57   ` Jakub Jelinek
2017-04-06 13:05     ` Martin Liška

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70b7d075-a235-b4d8-759f-b676b32d08a2@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).