From: Michihiro NAKAJIMA Date: Wed, 11 Feb 2009 13:44:52 +0000 (-0500) Subject: Do not use _waccess_s function. we cannot know X-Git-Tag: v2.7.0~301 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16170e87f83ab6e23b296262bd81a26fc6df16e8;p=thirdparty%2Flibarchive.git Do not use _waccess_s function. we cannot know whether a path is a directory. SVN-Revision: 605 --- diff --git a/libarchive/archive_windows.c b/libarchive/archive_windows.c index c91ebdfee..ec2108f18 100644 --- a/libarchive/archive_windows.c +++ b/libarchive/archive_windows.c @@ -283,6 +283,7 @@ __link(const char *src, const char *dst, int sym) { wchar_t *wsrc, *wdst; int res, retval; + DWORD attr; if (src == NULL || dst == NULL) { set_errno (EINVAL); @@ -300,7 +301,12 @@ __link(const char *src, const char *dst, int sym) return -1; } - if (!_waccess_s(wsrc, F_OK)) { + if ((attr = GetFileAttributesW(wsrc)) != -1) { + if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { + errno = EPERM; + retval = -1; + goto exit; + } if (!sym && canHardLinkW(wsrc, wdst)) res = CreateHardLinkW(wdst, wsrc, NULL); else @@ -347,7 +353,12 @@ __link(const char *src, const char *dst, int sym) wsrc[i] = L'\\'; wcsncat(wnewsrc, wsrc, n); /* Check again */ - if (_waccess_s(wnewsrc, R_OK)) { + attr = GetFileAttributesW(wnewsrc); + if (attr == -1 || (attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { + if (attr == -1) + _dosmaperr(GetLastError()); + else + errno = EPERM; free (wnewsrc); retval = -1; goto exit;