diff options
author | Christopher Faylor <me@cgf.cx> | 2000-12-15 22:25:51 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-12-15 22:25:51 +0000 |
commit | 7fbcbc95929b933657d8b69673c42d1dd84408b0 (patch) | |
tree | e5d27bd05731cc4aed3b388e64e8855749068b0b /winsup/cygwin/path.cc | |
parent | 80d0051c3714bed2c2c922f23b907d6ba11b19da (diff) | |
download | cygnal-7fbcbc95929b933657d8b69673c42d1dd84408b0.tar.gz cygnal-7fbcbc95929b933657d8b69673c42d1dd84408b0.tar.bz2 cygnal-7fbcbc95929b933657d8b69673c42d1dd84408b0.zip |
* 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.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 18 |
1 files changed, 10 insertions, 8 deletions
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); |