Internal change.

PiperOrigin-RevId: 615567691
This commit is contained in:
gVisor bot
2024-03-13 15:46:03 -07:00
parent d25ba02fee
commit 466008a821
3 changed files with 12 additions and 3 deletions
+4 -1
View File
@@ -15,6 +15,8 @@
#include <linux/capability.h>
#include <sys/socket.h>
#include <cstring>
#include "gtest/gtest.h"
#include "test/syscalls/linux/iptables.h"
#include "test/util/capability_util.h"
@@ -191,7 +193,8 @@ TEST(IP6TablesTest, InitialEntries) {
reinterpret_cast<char*>(entries->entrytable) + entry_offset);
// ipv6 should be zeroed.
struct ip6t_ip6 zeroed = {};
struct ip6t_ip6 zeroed;
memset(&zeroed, 0, sizeof(zeroed));
ASSERT_EQ(memcmp(static_cast<void*>(&zeroed),
static_cast<void*>(&entry->ipv6), sizeof(zeroed)),
0);
+3
View File
@@ -221,6 +221,9 @@ enum SockOpts6 {
// ip6t_ip6 specifies basic matching criteria that can be applied by examining
// only the IP header of a packet.
// Must be POD so that it can be zero-initialized using memset() because
// initializing by "{}" leaves it partially uninitialized for paddings and
// nested unions.
struct ip6t_ip6 {
// Source IP address.
struct in6_addr src;
+5 -2
View File
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <cstddef>
#include <cstring>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -220,13 +221,15 @@ TEST_F(TuntapTest, CreateFixedNameInterface) {
FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open(kDevNetTun, O_RDWR));
struct ifreq ifr_set = {};
struct ifreq ifr_set;
memset(&ifr_set, 0, sizeof(ifr_set));
ifr_set.ifr_flags = IFF_TAP;
strncpy(ifr_set.ifr_name, kTapName, IFNAMSIZ);
EXPECT_THAT(ioctl(fd.get(), TUNSETIFF, &ifr_set),
SyscallSucceedsWithValue(0));
struct ifreq ifr_get = {};
struct ifreq ifr_get;
memset(&ifr_get, 0, sizeof(ifr_get));
EXPECT_THAT(ioctl(fd.get(), TUNGETIFF, &ifr_get),
SyscallSucceedsWithValue(0));