aboutsummaryrefslogtreecommitdiff
path: root/sysvipc/test-sysvipc.h
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-09-29 14:45:09 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-10-02 16:11:59 -0300
commitbe9b0b9a012780a403a266c90878efffb9a5f3ca (patch)
tree35bbc1910849c6687267b06b24b84373e48a832d /sysvipc/test-sysvipc.h
parent20a00dbefca5695cccaa44846a482db8ccdd85ab (diff)
downloadglibc-be9b0b9a012780a403a266c90878efffb9a5f3ca.tar
glibc-be9b0b9a012780a403a266c90878efffb9a5f3ca.tar.gz
glibc-be9b0b9a012780a403a266c90878efffb9a5f3ca.tar.bz2
glibc-be9b0b9a012780a403a266c90878efffb9a5f3ca.zip
sysvipc: Return EINVAL for invalid msgctl commands
It avoids regressions on possible future commands that might require additional libc support. The downside is new commands added by newer kernels will need further glibc support. Checked on x86_64-linux-gnu and i686-linux-gnu (Linux v4.15 and v5.4).
Diffstat (limited to 'sysvipc/test-sysvipc.h')
-rw-r--r--sysvipc/test-sysvipc.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/sysvipc/test-sysvipc.h b/sysvipc/test-sysvipc.h
index d7ed496511..21ef6c6565 100644
--- a/sysvipc/test-sysvipc.h
+++ b/sysvipc/test-sysvipc.h
@@ -82,4 +82,29 @@ first_sem_invalid_cmd (void)
return invalid;
}
+/* Return the first invalid command SysV IPC command for message queue. */
+static inline int
+first_msg_invalid_cmd (void)
+{
+ const int msg_cmds[] = {
+ MSG_STAT,
+ MSG_INFO,
+#ifdef MSG_STAT_ANY
+ MSG_STAT_ANY,
+#endif
+ };
+
+ int invalid = first_common_invalid_cmd ();
+ for (int i = 0; i < array_length (msg_cmds); i++)
+ {
+ if (invalid == msg_cmds[i])
+ {
+ invalid++;
+ i = 0;
+ }
+ }
+
+ return invalid;
+}
+
#endif /* _TEST_SYSV_H */