[openssl-commits] [openssl] OpenSSL_1_1_0-stable update
Andy Polyakov
appro at openssl.org
Mon Jul 31 10:50:32 UTC 2017
The branch OpenSSL_1_1_0-stable has been updated
via e29ae5b356f40f7410d367b25d4e65e0dde0aeef (commit)
from a08f26660e0f8d2caf9462219ffea20d9e2c74f2 (commit)
- Log -----------------------------------------------------------------
commit e29ae5b356f40f7410d367b25d4e65e0dde0aeef
Author: Xiaoyin Liu <xiaoyinl at users.noreply.github.com>
Date: Sat Jul 22 01:57:27 2017 -0400
app_isdir() cleanup
I think it's better to use `GetFileAttributes` to obtain the attributes
of a file than `FindFirstFile`. If the input name contains `*`, this
function should return failure rather than check whether the first match
happens to be a file or a directory.
Reviewed-by: Andy Polyakov <appro at openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/3991)
(cherry picked from commit 5bd051a0dcd4f04bc9ea197f74b34612b3fcca84)
-----------------------------------------------------------------------
Summary of changes:
apps/apps.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/apps/apps.c b/apps/apps.c
index d3cb19d..0a38cb0 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -2255,29 +2255,27 @@ int app_access(const char* name, int flag)
#ifdef _WIN32
int app_isdir(const char *name)
{
- HANDLE hList;
- WIN32_FIND_DATA FileData;
+ DWORD attr;
# if defined(UNICODE) || defined(_UNICODE)
size_t i, len_0 = strlen(name) + 1;
+ WCHAR tempname[MAX_PATH];
- if (len_0 > OSSL_NELEM(FileData.cFileName))
+ if (len_0 > MAX_PATH)
return -1;
# if !defined(_WIN32_WCE) || _WIN32_WCE>=101
- if (!MultiByteToWideChar
- (CP_ACP, 0, name, len_0, FileData.cFileName, len_0))
+ if (!MultiByteToWideChar(CP_ACP, 0, name, len_0, tempname, MAX_PATH))
# endif
for (i = 0; i < len_0; i++)
- FileData.cFileName[i] = (WCHAR)name[i];
+ tempname[i] = (WCHAR)name[i];
- hList = FindFirstFile(FileData.cFileName, &FileData);
+ attr = GetFileAttributes(tempname);
# else
- hList = FindFirstFile(name, &FileData);
+ attr = GetFileAttributes(name);
# endif
- if (hList == INVALID_HANDLE_VALUE)
+ if (attr == INVALID_FILE_ATTRIBUTES)
return -1;
- FindClose(hList);
- return ((FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
+ return ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0);
}
#else
# include <sys/stat.h>
More information about the openssl-commits
mailing list