From 7fbcbc95929b933657d8b69673c42d1dd84408b0 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 15 Dec 2000 22:25:51 +0000 Subject: [PATCH] * path.cc (normalize_posix_path): Calculate path name length overruns more dynamically. (normalize_win32_path): Ditto. * Makefile.in: Avoid scanning the directory twice for *.d files. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/Makefile.in | 5 +++-- winsup/cygwin/path.cc | 18 ++++++++++-------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 508f05d3d..98e33d637 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +Fri Dec 15 17:23:17 2000 Christopher Faylor + + * path.cc (normalize_posix_path): Calculate path name length overruns + more dynamically. + (normalize_win32_path): Ditto. + * Makefile.in: Avoid scanning the directory twice for *.d files. + Thu Dec 14 23:37:51 2000 Christopher Faylor * fhandler.h (fhandler_console): Add additional argument to diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 37f4c9623..18dbdc7c0 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -219,6 +219,7 @@ $(DEF_FILE): cygwin.din config.status winsup.h: config.h -ifneq (,${wildcard *.d}) -include *.d +deps:=${wildcard *.d} +ifneq (,$(deps)) +include $(deps) endif diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 0584d03e5..69f607163 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -608,11 +608,6 @@ normalize_posix_path (const char *src, char *dst) { if (!cygcwd.get (dst)) return get_errno (); - if (strlen (dst) + 1 + strlen (src) >= MAX_PATH) - { - debug_printf ("ENAMETOOLONG = normalize_posix_path (%s)", src); - return ENAMETOOLONG; - } dst = strchr (dst, '\0'); if (*src == '.') { @@ -647,6 +642,8 @@ normalize_posix_path (const char *src, char *dst) strcpy (dst, cygheap->root.path ()); dst += cygheap->root.length (); } + else + *dst = '\0'; while (*src) { @@ -689,6 +686,11 @@ normalize_posix_path (const char *src, char *dst) *dst++ = '/'; } + if ((dst - dst_start) >= MAX_PATH) + { + debug_printf ("ENAMETOOLONG = normalize_posix_path (%s)", src); + return ENAMETOOLONG; + } } done: @@ -768,9 +770,7 @@ normalize_win32_path (const char *src, char *dst) /* Ignore "./". */ else if (src[0] == '.' && SLASH_P (src[1]) && (src == src_start || SLASH_P (src[-1]))) - { - src += 2; - } + src += 2; /* Backup if "..". */ else if (src[0] == '.' && src[1] == '.' @@ -797,6 +797,8 @@ normalize_win32_path (const char *src, char *dst) *dst++ = *src; ++src; } + if ((dst - dst_start) >= MAX_PATH) + return ENAMETOOLONG; } *dst = 0; debug_printf ("%s = normalize_win32_path (%s)", dst_start, src_start);