aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2009-10-02 06:04:57 +0000
committerChristopher Faylor <me@cgf.cx>2009-10-02 06:04:57 +0000
commit284c5ea0a57bd6d5aa1b3159fddc19fb7181beab (patch)
treedec389159e6467ed6929baec5f08668553e1e464
parent182f0f0f8c4c39cba7f3022d27b21fba28c68734 (diff)
downloadnewlib-284c5ea0a57bd6d5aa1b3159fddc19fb7181beab.zip
newlib-284c5ea0a57bd6d5aa1b3159fddc19fb7181beab.tar.gz
newlib-284c5ea0a57bd6d5aa1b3159fddc19fb7181beab.tar.bz2
* dcrt0.cc (dll_crt0_1): Move cxx_malloc reset kluge from here.
(check_sanity_and_sync): to here. * path.cc (has_dot_last_component): Rewrite to detect some corner cases that were previously uncaught.
-rw-r--r--winsup/cygwin/ChangeLog10
-rw-r--r--winsup/cygwin/dcrt0.cc12
-rw-r--r--winsup/cygwin/path.cc43
3 files changed, 42 insertions, 23 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index a74484e..0ecfb5f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-02 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * dcrt0.cc (dll_crt0_1): Move cxx_malloc reset kluge from here.
+ (check_sanity_and_sync): to here.
+
+2009-09-30 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * path.cc (has_dot_last_component): Rewrite to detect some corner cases
+ that were previously uncaught.
+
2009-09-30 Corinna Vinschen <corinna@vinschen.de>
* fhandler_console.cc (beep): Move up to avoid forward declaration.
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index e142b74..6e41292 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -375,6 +375,12 @@ check_sanity_and_sync (per_process *p)
if (p->api_major > cygwin_version.api_major)
api_fatal ("cygwin DLL and APP are out of sync -- API version mismatch %d > %d",
p->api_major, cygwin_version.api_major);
+
+ /* This is a kludge to work around a version of _cygwin_common_crt0
+ which overwrote the cxx_malloc field with the local DLL copy.
+ Hilarity ensues if the DLL is not loaded while the process
+ is forking. */
+ __cygwin_user_data.cxx_malloc = &default_cygwin_cxx_malloc;
}
child_info NO_COPY *child_proc_info = NULL;
@@ -766,12 +772,6 @@ dll_crt0_1 (void *)
sigproc_init ();
check_sanity_and_sync (user_data);
- /* This is a kludge to work around a version of _cygwin_common_crt0
- which overwrote the cxx_malloc field with the local DLL copy.
- Hilarity ensues if the DLL is not loaded like while the process
- is forking. */
- __cygwin_user_data.cxx_malloc = &default_cygwin_cxx_malloc;
-
/* Initialize malloc and then call user_shared_initialize since it relies
on a functioning malloc and it's possible that the user's program may
have overridden malloc. We only know about that at this stage,
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index e543dd4..7e89cb0 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -203,23 +203,32 @@ has_dot_last_component (const char *dir, bool test_dot_dot)
/* SUSv3: . and .. are not allowed as last components in various system
calls. Don't test for backslash path separator since that's a Win32
path following Win32 rules. */
- const char *last_comp = strrchr (dir, '/');
- if (!last_comp)
- last_comp = dir;
- else {
- /* Check for trailing slash. If so, hop back to the previous slash. */
- if (!last_comp[1])
- while (last_comp > dir)
- if (*--last_comp == '/')
- break;
- if (*last_comp == '/')
- ++last_comp;
- }
- return last_comp[0] == '.'
- && ((last_comp[1] == '\0' || last_comp[1] == '/')
- || (test_dot_dot
- && last_comp[1] == '.'
- && (last_comp[2] == '\0' || last_comp[2] == '/')));
+ const char *last_comp = strchr (dir, '\0');
+
+ if (last_comp == dir)
+ return false; /* Empty string. Probably shouldn't happen here? */
+
+ /* Detect run of trailing slashes */
+ while (last_comp > dir && *--last_comp == '/')
+ continue;
+
+ /* Detect just a run of slashes or a path that does not end with a slash. */
+ if (*last_comp != '.')
+ return false;
+
+ /* We know we have a trailing dot here. Check that it really is a standalone "."
+ path component by checking that it is at the beginning of the string or is
+ preceded by a "/" */
+ if (last_comp == dir || *--last_comp == '/')
+ return true;
+
+ /* If we're not checking for '..' we're done. Ditto if we're now pointing to
+ a non-dot. */
+ if (!test_dot_dot || *last_comp != '.')
+ return false; /* either not testing for .. or this was not '..' */
+
+ /* Repeat previous test for standalone or path component. */
+ return last_comp == dir || last_comp[-1] == '/';
}
/* Normalize a POSIX path.