]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Avoid the bug of GetFullPathNameW.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 26 Dec 2011 18:02:25 +0000 (13:02 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 26 Dec 2011 18:02:25 +0000 (13:02 -0500)
There is a case that GetFullPathNameW cannot return a sufficient buffer size
when the length of the file name pass to that function is one.

SVN-Revision: 4007

libarchive/archive_windows.c

index ad75c0c1461ffe4b314f0cccfdcfc9620fdda409..f8e8e46667f972df0552ffb04f3db6927241a0c4 100644 (file)
@@ -135,6 +135,11 @@ __la_win_permissive_name_w(const wchar_t *wname)
        l = GetFullPathNameW(wname, 0, NULL, NULL);
        if (l == 0)
                return (NULL);
+       /* NOTE: GetFullPathNameW has a bug that if the length of the file
+        * name is just one that return imcomplete buffer size. Thus, we 
+        * have to add three to the size to allocate a sufficient buffer
+        * size for the full-pathname of the file name. */
+       l += 3;
        wnp = malloc(l * sizeof(wchar_t));
        if (wnp == NULL)
                return (NULL);