sys_msg_test: Fix msgsnd() argument passing

msgsnd() takes the following arguments:
1. msqid: the message queue ID
2. msgp: a pointer to a struct whose first member is the message
   type (long) and the second the message itself (char array).
3. msgsz: the size of the message
4. msgflg: optional flags

sys_msg.smoke does not correctly specify msgsz, as it provides the
size of the whole struct instead of its message (data) member.
sys_msg.msgsnd_failure does not provide a pointer to a full struct
as msgp. In both cases, this results in the kernel reading garbage
on the stack.

Fix both issues by providing the appropriate size and struct
pointer.

Test: run bionic-tests --gtest_filter=sys_msg.*
Change-Id: Iaa005e259d3ecfa28484dd66222ed6c4584ffc08
diff --git a/tests/sys_msg_test.cpp b/tests/sys_msg_test.cpp
index da45087..b2d855d 100644
--- a/tests/sys_msg_test.cpp
+++ b/tests/sys_msg_test.cpp
@@ -56,16 +56,17 @@
     long type;
     char data[32];
   } msg = { 1, "hello world" };
-  ASSERT_EQ(0, msgsnd(id, &msg, sizeof(msg), 0));
+  ASSERT_EQ(0, msgsnd(id, &msg, sizeof(msg.data), 0));
 
   // Queue should be non-empty.
   ASSERT_EQ(0, msgctl(id, IPC_STAT, &ds));
   ASSERT_EQ(1U, ds.msg_qnum);
-  ASSERT_EQ(sizeof(msg), ds.msg_cbytes);
+  ASSERT_EQ(sizeof(msg.data), ds.msg_cbytes);
 
   // Read the message.
   memset(&msg, 0, sizeof(msg));
-  ASSERT_EQ(static_cast<ssize_t>(sizeof(msg)), msgrcv(id, &msg, sizeof(msg), 0, 0));
+  ASSERT_EQ(static_cast<ssize_t>(sizeof(msg.data)),
+            msgrcv(id, &msg, sizeof(msg.data), 0, 0));
   ASSERT_EQ(1, msg.type);
   ASSERT_STREQ("hello world", msg.data);
 
@@ -98,7 +99,11 @@
 }
 
 TEST(sys_msg, msgsnd_failure) {
+  struct {
+    long type;
+    char data[1];
+  } msg = { 1, "" };
   errno = 0;
-  ASSERT_EQ(-1, msgsnd(-1, "", 0, 0));
+  ASSERT_EQ(-1, msgsnd(-1, &msg, sizeof(msg.data), 0));
   ASSERT_TRUE(errno == EINVAL || errno == ENOSYS);
 }