+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.
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;
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,
/* 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.