diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-04-28 12:05:18 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-04-28 12:05:18 +0000 |
commit | ce09cd5400c964098d227b17e7e26bff3c2cf8c8 (patch) | |
tree | 2a2f608fa0817004ed6585da6a960d7de244899b /Build/source/texk/kpathsea | |
parent | c7e9c7395503b1d19d3d82c151139e8a87ff498f (diff) |
improve long path support (windows only)
git-svn-id: svn://tug.org/texlive/trunk@54925 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea')
-rw-r--r-- | Build/source/texk/kpathsea/knj.c | 24 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/readable.c | 9 |
2 files changed, 21 insertions, 12 deletions
diff --git a/Build/source/texk/kpathsea/knj.c b/Build/source/texk/kpathsea/knj.c index 0d26b5d92e4..147f7e084c7 100644 --- a/Build/source/texk/kpathsea/knj.c +++ b/Build/source/texk/kpathsea/knj.c @@ -118,19 +118,23 @@ kpathsea_fsyscp_xfopen (kpathsea kpse, const char *filename, const char *mode) int i; unsigned char *fnn; unsigned char *p; + size_t len; + assert(filename && mode); + len = strlen(filename); /* Support very long input path name, longer than _MAX_PATH for Windows, if it really exists and input name is given in full-absolute path in a command line. */ - fnn = xmalloc(strlen(filename) + 10); - if ((filename[0] == '/' && filename[1] == '/') || - (filename[0] == '\\' && filename[1] == '\\' && filename[2] != '?')) { + fnn = xmalloc(len + 10); + if (len > 2 && ((filename[0] == '/' && filename[1] == '/') || + (filename[0] == '\\' && filename[1] == '\\' && + filename[2] != '?'))) { filename += 2; strcpy (fnn, "\\\\?\\UNC\\"); strcat (fnn, filename); - } else if (filename[1] == ':') { + } else if (len > 2 && filename[1] == ':') { strcpy (fnn, "\\\\?\\"); strcat (fnn, filename); } else { @@ -174,19 +178,23 @@ kpathsea_fsyscp_fopen (kpathsea kpse, const char *filename, const char *mode) int i; unsigned char *fnn; unsigned char *p; + size_t len; + assert(filename && mode); + len = strlen(filename); /* Support very long input path name, longer than _MAX_PATH for Windows, if it really exists and input name is given in full-absolute path in a command line. */ - fnn = xmalloc(strlen(filename) + 10); - if ((filename[0] == '/' && filename[1] == '/') || - (filename[0] == '\\' && filename[1] == '\\' && filename[2] != '?')) { + fnn = xmalloc(len + 10); + if (len > 2 && ((filename[0] == '/' && filename[1] == '/') || + (filename[0] == '\\' && filename[1] == '\\' && + filename[2] != '?'))) { filename += 2; strcpy (fnn, "\\\\?\\UNC\\"); strcat (fnn, filename); - } else if (filename[1] == ':') { + } else if (len > 2 && filename[1] == ':') { strcpy (fnn, "\\\\?\\"); strcat (fnn, filename); } else { diff --git a/Build/source/texk/kpathsea/readable.c b/Build/source/texk/kpathsea/readable.c index a6dc1233f1a..8f4f94fa8c7 100644 --- a/Build/source/texk/kpathsea/readable.c +++ b/Build/source/texk/kpathsea/readable.c @@ -43,19 +43,20 @@ READABLE(kpathsea kpse, const_string fn, unsigned int st) wchar_t *fnw; unsigned char *fnn; unsigned char *p; + size_t len = strlen(fn); - fnn = xmalloc(strlen(fn) + 10); + fnn = xmalloc(len + 10); /* Support very long input path name, longer than _MAX_PATH for Windows, if it really exists and input name is given in full-absolute path in a command line. */ - if ((fn[0] == '/' && fn[1] == '/') || - (fn[0] == '\\' && fn[1] == '\\' && fn[2] != '?')) { + if (len > 2 && ((fn[0] == '/' && fn[1] == '/') || + (fn[0] == '\\' && fn[1] == '\\' && fn[2] != '?'))) { fn += 2; strcpy (fnn, "\\\\?\\UNC\\"); strcat (fnn, fn); - } else if (fn[1] == ':') { + } else if (len > 2 && fn[1] == ':') { strcpy (fnn, "\\\\?\\"); strcat (fnn, fn); } else { |