summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/msgqueue.cc
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2021-08-24 15:23:14 -0700
committergVisor bot <gvisor-bot@google.com>2021-08-24 15:26:29 -0700
commit19051dd26fe4840cdeb599f6fb393bf72851b4ee (patch)
tree1c81ec16a70462c80716b233baae439379d83b4b /test/syscalls/linux/msgqueue.cc
parent2c3d7cb074f2406c058bf6cce8c2a050fa453165 (diff)
Fix uninitialized messages in MsgqueueTest
PiperOrigin-RevId: 392760305
Diffstat (limited to 'test/syscalls/linux/msgqueue.cc')
-rw-r--r--test/syscalls/linux/msgqueue.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/syscalls/linux/msgqueue.cc b/test/syscalls/linux/msgqueue.cc
index aaf46625d..c4761eba8 100644
--- a/test/syscalls/linux/msgqueue.cc
+++ b/test/syscalls/linux/msgqueue.cc
@@ -731,8 +731,9 @@ TEST(MsgqueueTest, MsgCtlIpcStat) {
absl::SleepFor(absl::Seconds(1));
auto pre_send = absl::Now();
- msgbuf buf;
- ASSERT_THAT(msgsnd(queue.get(), &buf, msgSize, 0), SyscallSucceeds());
+ msgbuf buf{1, "A message."};
+ ASSERT_THAT(msgsnd(queue.get(), &buf, sizeof(buf.mtext), 0),
+ SyscallSucceeds());
ASSERT_THAT(msgctl(queue.get(), IPC_STAT, &ds), SyscallSucceeds());
@@ -749,7 +750,7 @@ TEST(MsgqueueTest, MsgCtlIpcStat) {
absl::SleepFor(absl::Seconds(1));
auto pre_receive = absl::Now();
- ASSERT_THAT(msgrcv(queue.get(), &buf, msgSize, 0, 0),
+ ASSERT_THAT(msgrcv(queue.get(), &buf, sizeof(buf.mtext), 0, 0),
SyscallSucceedsWithValue(msgSize));
ASSERT_THAT(msgctl(queue.get(), IPC_STAT, &ds), SyscallSucceeds());
@@ -850,8 +851,9 @@ TEST(MsgqueueTest, MsgCtlMsgInfo) {
Queue queue(msgget(IPC_PRIVATE, 0600));
ASSERT_THAT(queue.get(), SyscallSucceeds());
- msgbuf buf;
- ASSERT_THAT(msgsnd(queue.get(), &buf, msgSize, 0), SyscallSucceeds());
+ msgbuf buf{1, "A message."};
+ ASSERT_THAT(msgsnd(queue.get(), &buf, sizeof(buf.mtext), 0),
+ SyscallSucceeds());
ASSERT_THAT(msgctl(0, MSG_INFO, reinterpret_cast<struct msqid_ds*>(&info)),
SyscallSucceeds());