diff options
author | Ting-Yu Wang <anivia@google.com> | 2021-01-15 15:03:30 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-15 15:10:27 -0800 |
commit | ec9e263f213c59e93f9c8b8123012b3db2dddc9a (patch) | |
tree | 87f0fca5791ece2a138fe822b4067569425f6bd2 /test/syscalls/linux/socket_test_util.cc | |
parent | 55c7fe48d223ee5678dff7f5bf9a9e5f0482ab37 (diff) |
Correctly return EMSGSIZE when packet is too big in raw socket.
IPv4 previously accepts the packet, while IPv6 panics. Neither is the behavior
in Linux.
splice() in Linux has different behavior than in gVisor. This change documents
it in the SpliceTooLong test.
Reported-by: syzbot+b550e78e5c24d1d521f2@syzkaller.appspotmail.com
PiperOrigin-RevId: 352091286
Diffstat (limited to 'test/syscalls/linux/socket_test_util.cc')
-rw-r--r-- | test/syscalls/linux/socket_test_util.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_test_util.cc b/test/syscalls/linux/socket_test_util.cc index 26dacc95e..b2a96086c 100644 --- a/test/syscalls/linux/socket_test_util.cc +++ b/test/syscalls/linux/socket_test_util.cc @@ -791,6 +791,19 @@ void RecvNoData(int sock) { SyscallFailsWithErrno(EAGAIN)); } +TestAddress TestAddress::WithPort(uint16_t port) const { + TestAddress addr = *this; + switch (addr.family()) { + case AF_INET: + reinterpret_cast<sockaddr_in*>(&addr.addr)->sin_port = htons(port); + break; + case AF_INET6: + reinterpret_cast<sockaddr_in6*>(&addr.addr)->sin6_port = htons(port); + break; + } + return addr; +} + TestAddress V4Any() { TestAddress t("V4Any"); t.addr.ss_family = AF_INET; |