|
|
Message-ID: <1556443913-18270-1-git-send-email-h.huangqiang@huawei.com>
Date: Sun, 28 Apr 2019 05:31:53 -0400
From: Qiang Huang <h.huangqiang@...wei.com>
To: <musl@...ts.openwall.com>
Subject: [PATCH] mq_open: Perform check for mq name
According to Linux man page:
[http://man7.org/linux/man-pages/man2/mq_open.2.html]
```
C library/kernel differences
The mq_open() library function is implemented on top of a system call
of the same name. The library function performs the check that the
name starts with a slash (/), giving the EINVAL error if it does not.
The kernel system call expects name to contain no preceding slash, so
the C library function passes name without the preceding slash (i.e.,
name+1) to the system call.
```
glibc performs the check but musl doesn't, add the
check so we can have consistent behavior.
Signed-off-by: Qiang Huang <h.huangqiang@...wei.com>
---
src/mq/mq_open.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/mq/mq_open.c b/src/mq/mq_open.c
index aa91d58..e626228 100644
--- a/src/mq/mq_open.c
+++ b/src/mq/mq_open.c
@@ -1,12 +1,14 @@
#include <mqueue.h>
#include <fcntl.h>
#include <stdarg.h>
+#include <errno.h>
#include "syscall.h"
mqd_t mq_open(const char *name, int flags, ...)
{
mode_t mode = 0;
struct mq_attr *attr = 0;
+ if (name[0] != '/') return __syscall_ret(-EINVAL);
if (*name == '/') name++;
if (flags & O_CREAT) {
va_list ap;
--
2.7.4
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.