summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/posix_ipc.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-06-12 09:50:05 +0000
committerCorinna Vinschen <corinna@vinschen.de>2009-06-12 09:50:05 +0000
commitb32c31d117ca1a44ee4d3f9cf086e7ad659e1895 (patch)
tree155d5882bd80d87a9ec5ef05c92c74e890dd6e05 /winsup/cygwin/posix_ipc.cc
parent297abffd6721a322f719a4dbf9c7a94610cb1e84 (diff)
downloadcygnal-b32c31d117ca1a44ee4d3f9cf086e7ad659e1895.tar.gz
cygnal-b32c31d117ca1a44ee4d3f9cf086e7ad659e1895.tar.bz2
cygnal-b32c31d117ca1a44ee4d3f9cf086e7ad659e1895.zip
* posix_ipc.cc (check_path): Fix typo in comment. Align naming
convention rules to Linux. Add comment.
Diffstat (limited to 'winsup/cygwin/posix_ipc.cc')
-rw-r--r--winsup/cygwin/posix_ipc.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc
index 693b65498..2578f545b 100644
--- a/winsup/cygwin/posix_ipc.cc
+++ b/winsup/cygwin/posix_ipc.cc
@@ -47,7 +47,7 @@ enum ipc_type_t
static bool
check_path (char *res_name, ipc_type_t type, const char *name, size_t len)
{
- /* Note that we require the existance of the apprpriate /dev subdirectories
+ /* Note that we require the existance of the appropriate /dev subdirectories
for POSIX IPC object support, similar to Linux (which supports the
directories, but doesn't require to mount them). We don't create
these directory here, that's the task of the installer. But we check
@@ -65,13 +65,21 @@ check_path (char *res_name, ipc_type_t type, const char *name, size_t len)
set_errno (EINVAL);
return false;
}
- /* Name must start with a single slash. */
- if (!name || name[0] != '/' || name[1] == '/' || !name[1])
+ /* Name must not be empty, or just be a single slash, or start with more
+ than one slash. Same for backslash.
+ Apart from handling backslash like slash, the naming rules are identical
+ to Linux, including the names and requirements for subdirectories, if
+ the name contains further slashes. */
+ if (!name || (strchr ("/\\", name[0])
+ && (!name[1] || strchr ("/\\", name[1]))))
{
debug_printf ("Invalid %s name '%s'", ipc_names[type].description, name);
set_errno (EINVAL);
return false;
}
+ /* Skip leading (back-)slash. */
+ if (strchr ("/\\", name[0]))
+ ++name;
if (len > PATH_MAX - ipc_names[type].prefix_len)
{
debug_printf ("%s name '%s' too long", ipc_names[type].description, name);
@@ -80,7 +88,7 @@ check_path (char *res_name, ipc_type_t type, const char *name, size_t len)
}
__small_sprintf (res_name, "%s/%s%s", ipc_names[type].prefix,
type == semaphore ? "sem." : "",
- name + 1);
+ name);
return true;
}