From: Michihiro NAKAJIMA Date: Mon, 26 Dec 2011 18:02:25 +0000 (-0500) Subject: Avoid the bug of GetFullPathNameW. X-Git-Tag: v3.0.4~2^2~255 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50e37860e235e217865d8e9d72b27623914c101d;p=thirdparty%2Flibarchive.git Avoid the bug of GetFullPathNameW. 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 --- diff --git a/libarchive/archive_windows.c b/libarchive/archive_windows.c index ad75c0c14..f8e8e4666 100644 --- a/libarchive/archive_windows.c +++ b/libarchive/archive_windows.c @@ -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);