From: Jan Kiszka <jan.kiszka@domain.hid>
To: xenomai-core <xenomai@xenomai.org>
Subject: [Xenomai-core] [PATCH] posix: Fix error checks when copying user strings
Date: Wed, 18 Mar 2009 10:24:56 +0100 [thread overview]
Message-ID: <49C0BDE8.4050400@domain.hid> (raw)
Do not return -EFAULT when the passed string has zero-length. Instead,
return -EINVAL when trying to create objects with empty names.
Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
ksrc/skins/posix/syscall.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/ksrc/skins/posix/syscall.c b/ksrc/skins/posix/syscall.c
index 16303b3..c7950a6 100644
--- a/ksrc/skins/posix/syscall.c
+++ b/ksrc/skins/posix/syscall.c
@@ -600,6 +600,8 @@ static int __sem_open(struct pt_regs *regs)
if (len >= sizeof(name))
return -ENAMETOOLONG;
+ if (len == 0)
+ return -EINVAL;
oflags = __xn_reg_arg3(regs);
@@ -1663,11 +1665,13 @@ static int __mq_open(struct pt_regs *regs)
len = __xn_safe_strncpy_from_user(name,
(const char __user *)__xn_reg_arg1(regs),
sizeof(name));
- if (len <= 0)
+ if (len < 0)
return -EFAULT;
if (len >= sizeof(name))
return -ENAMETOOLONG;
+ if (len == 0)
+ return -EINVAL;
oflags = __xn_reg_arg2(regs);
mode = __xn_reg_arg3(regs);
@@ -1736,7 +1740,7 @@ static int __mq_unlink(struct pt_regs *regs)
len = __xn_safe_strncpy_from_user(name,
(const char __user *)__xn_reg_arg1(regs),
sizeof(name));
- if (len <= 0)
+ if (len < 0)
return -EFAULT;
if (len >= sizeof(name))
@@ -2440,11 +2444,13 @@ static int __shm_open(struct pt_regs *regs)
len = __xn_safe_strncpy_from_user(name,
(const char __user *)__xn_reg_arg1(regs),
sizeof(name));
- if (len <= 0)
+ if (len < 0)
return -EFAULT;
if (len >= sizeof(name))
return -ENAMETOOLONG;
+ if (len == 0)
+ return -EINVAL;
oflag = (int)__xn_reg_arg2(regs);
mode = (mode_t) __xn_reg_arg3(regs);
@@ -2487,7 +2493,7 @@ static int __shm_unlink(struct pt_regs *regs)
len = __xn_safe_strncpy_from_user(name,
(const char __user *)__xn_reg_arg1(regs),
sizeof(name));
- if (len <= 0)
+ if (len < 0)
return -EFAULT;
if (len >= sizeof(name))
next reply other threads:[~2009-03-18 9:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-18 9:24 Jan Kiszka [this message]
2009-03-18 10:03 ` [Xenomai-core] [PATCH] posix: Fix error checks when copying user strings Gilles Chanteperdrix
-- strict thread matches above, loose matches on Subject: below --
2009-03-17 18:35 Jan Kiszka
2009-03-17 18:41 ` Gilles Chanteperdrix
2009-03-17 18:49 ` Jan Kiszka
2009-03-17 18:51 ` Gilles Chanteperdrix
2009-03-17 19:00 ` Jan Kiszka
2009-03-17 19:01 ` Gilles Chanteperdrix
2009-03-17 19:09 ` Jan Kiszka
2009-03-17 19:13 ` Jan Kiszka
2009-03-17 19:36 ` Jan Kiszka
2009-03-17 19:42 ` Gilles Chanteperdrix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49C0BDE8.4050400@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.