EXPECT_NOT_POISONED(gids[i]);
}
+TEST(MemorySanitizer, getgroups_zero) {
+ gid_t group;
+ int n = getgroups(0, &group);
+ ASSERT_GE(n, 0);
+}
+
+TEST(MemorySanitizer, getgroups_negative) {
+ gid_t group;
+ int n = getgroups(-1, 0);
+ ASSERT_EQ(-1, n);
+
+ n = getgroups(-1, 0);
+ ASSERT_EQ(-1, n);
+}
+
TEST(MemorySanitizer, wordexp) {
wordexp_t w;
int res = wordexp("a b c", &w, 0);
// 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);