summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dir.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/dir.c b/src/dir.c
index 862a18ea..2b2abf33 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -1286,13 +1286,13 @@ local_stat (const char *path, struct stat *buf)
/* Make sure the parent of "." exists and is a directory, not a
file. This is because 'stat' on Windows normalizes the argument
foo/. => foo without checking first that foo is a directory. */
- if (plen > 1 && path[plen - 1] == '.'
+ if (plen > 2 && path[plen - 1] == '.'
&& (path[plen - 2] == '/' || path[plen - 2] == '\\'))
{
- char parent[MAXPATHLEN];
+ char parent[MAXPATHLEN+1];
- strncpy (parent, path, plen - 2);
- parent[plen - 2] = '\0';
+ strncpy (parent, path, MAXPATHLEN);
+ parent[MIN(plen - 2, MAXPATHLEN)] = '\0';
if (stat (parent, buf) < 0 || !_S_ISDIR (buf->st_mode))
return -1;
}