From 8aacd7b80265d5a0eea9b7603ed5633b3f701c60 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 29 Apr 2019 20:47:52 -0700 Subject: [PATCH] Fix for read directory functions with Windows (`wc_ReadDirFirst` and `wc_ReadDirNext`). Fix to use bit-mask check instead of equality. --- wolfcrypt/src/wc_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index d61c25c98..7f9b5688c 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -291,7 +291,7 @@ int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name) } do { - if (ctx->FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) { + if (!(ctx->FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { dnameLen = (int)XSTRLEN(ctx->FindFileData.cFileName); if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) { @@ -427,7 +427,7 @@ int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name) #ifdef USE_WINDOWS_API while (FindNextFileA(ctx->hFind, &ctx->FindFileData)) { - if (ctx->FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) { + if (!(ctx->FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { dnameLen = (int)XSTRLEN(ctx->FindFileData.cFileName); if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {