From 9e68bb7b50888ba3ff1c2bbcef78e6f6c9f1b4a0 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 27 Dec 2005 18:10:49 +0000 Subject: [PATCH] * path.cc (path_conv::check): Rework loop removing trailing dots and spaces. * syslog.cc (vklog): Set facility to LOG_KERN if not set. --- winsup/cygwin/path.cc | 26 +++++++++++++++++--------- winsup/cygwin/syslog.cc | 2 ++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index f2b56cf1f..8fc616ef4 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -955,18 +955,26 @@ out: { if (strncmp (path, "\\\\.\\", 4)) { - /* Windows ignores trailing dots and spaces */ + /* Windows ignores trailing dots and spaces in the last path + component, and ignores exactly one trailing dot in inner + path components. */ char *tail = NULL; for (char *p = path; *p; p++) - if (*p != '.' && *p != ' ') - tail = NULL; - else if (p[1] == '\\') - { - memmove (p, p + 1, strlen (p)); + { + if (*p != '.' && *p != ' ') tail = NULL; - } - else if (!tail) - tail = p; + else if (!tail) + tail = p; + if (tail && p[1] == '\\') + { + if (p > tail || *tail != '.') + { + error = ENOENT; + return; + } + tail = NULL; + } + } if (!tail || tail == path) /* nothing */; diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc index fc6758b62..2ea0d6207 100644 --- a/winsup/cygwin/syslog.cc +++ b/winsup/cygwin/syslog.cc @@ -484,6 +484,8 @@ vklog (int priority, const char *message, va_list ap) /* TODO: kernel messages are under our control entirely and they should be quick. No playing with /dev/null, but a fixed upper size for now. */ char buf[2060]; /* 2048 + a prority */ + if (!(priority & ~LOG_PRIMASK)) + priority = LOG_KERN | LOG_PRI (priority); __small_sprintf (buf, "<%d>", priority); __small_vsprintf (buf + strlen (buf), message, ap); klog_guard.init ("klog_guard")->acquire ();