diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a74484ea3..0ecfb5f1a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2009-10-02 Christopher Faylor + + * dcrt0.cc (dll_crt0_1): Move cxx_malloc reset kluge from here. + (check_sanity_and_sync): to here. + +2009-09-30 Christopher Faylor + + * path.cc (has_dot_last_component): Rewrite to detect some corner cases + that were previously uncaught. + 2009-09-30 Corinna Vinschen * fhandler_console.cc (beep): Move up to avoid forward declaration. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index e142b74c5..6e4129298 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 e543dd4b7..7e89cb050 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.