From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14097 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Qiang Huang Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] mq_open: Perform check for mq name Date: Sun, 28 Apr 2019 05:31:53 -0400 Message-ID: <1556443913-18270-1-git-send-email-h.huangqiang@huawei.com> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="141054"; mail-complaints-to="usenet@blaine.gmane.org" To: Original-X-From: musl-return-14113-gllmg-musl=m.gmane.org@lists.openwall.com Sun Apr 28 11:21:17 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hKfzn-000aVW-0L for gllmg-musl@m.gmane.org; Sun, 28 Apr 2019 11:21:15 +0200 Original-Received: (qmail 3993 invoked by uid 550); 28 Apr 2019 09:21:10 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3958 invoked from network); 28 Apr 2019 09:21:09 -0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [10.175.103.86] X-CFilter-Loop: Reflected Xref: news.gmane.org gmane.linux.lib.musl.general:14097 Archived-At: 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 --- 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 #include #include +#include #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