From b32c31d117ca1a44ee4d3f9cf086e7ad659e1895 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 12 Jun 2009 09:50:05 +0000 Subject: * posix_ipc.cc (check_path): Fix typo in comment. Align naming convention rules to Linux. Add comment. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/posix_ipc.cc | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 68c222a78..85604eaca 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2009-06-12 Corinna Vinschen + + * posix_ipc.cc (check_path): Fix typo in comment. Align naming + convention rules to Linux. Add comment. + 2009-06-09 Corinna Vinschen * autoload.cc (GetSystemTimes): Remove. 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; } -- cgit v1.2.3