INTIME: support CRL for INTIME version < 6

This commit is contained in:
Elms
2021-04-01 10:21:45 -07:00
parent fd94d05b0a
commit 379e1fb630
2 changed files with 37 additions and 11 deletions

View File

@@ -508,14 +508,14 @@ int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name)
XSTRNCPY(ctx->name, path, MAX_FILENAME_SZ - 3);
XSTRNCPY(ctx->name + pathLen, "\\*", MAX_FILENAME_SZ - pathLen);
if (!FindFirstRtFile(ctx->name, &ctx->FindFileData, 0)) {
if (!IntimeFindFirst(ctx->name, &ctx->FindFileData)) {
WOLFSSL_MSG("FindFirstFile for path verify locations failed");
return BAD_PATH_ERROR;
}
do {
if (!(ctx->FindFileData.dwFileAttributes & FILE_ATTR_DIRECTORY)) {
dnameLen = (int)XSTRLEN(ctx->FindFileData.cFileName);
if (IntimeNormalFile(ctx)) {
dnameLen = (int)XSTRLEN(IntimeFilename(ctx));
if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
return BAD_PATH_ERROR;
@@ -523,13 +523,13 @@ int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name)
XSTRNCPY(ctx->name, path, pathLen + 1);
ctx->name[pathLen] = '\\';
XSTRNCPY(ctx->name + pathLen + 1,
ctx->FindFileData.cFileName,
IntimeFilename(ctx),
MAX_FILENAME_SZ - pathLen - 1);
if (name)
*name = ctx->name;
return 0;
}
} while (FindNextRtFile(&ctx->FindFileData));
} while (IntimeFindNext(&ctx->FindFileData));
#elif defined(WOLFSSL_ZEPHYR)
if (fs_opendir(&ctx->dir, path) != 0) {
@@ -656,9 +656,9 @@ int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name)
}
#elif defined(INTIME_RTOS)
while (FindNextRtFile(&ctx->FindFileData)) {
if (!(ctx->FindFileData.dwFileAttributes & FILE_ATTR_DIRECTORY)) {
dnameLen = (int)XSTRLEN(ctx->FindFileData.cFileName);
while (IntimeFindNext(&ctx->FindFileData)) {
if (IntimeNormalFile(ctx)) {
dnameLen = (int)XSTRLEN(IntimeFilename(ctx));
if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
return BAD_PATH_ERROR;
@@ -666,7 +666,7 @@ int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name)
XSTRNCPY(ctx->name, path, pathLen + 1);
ctx->name[pathLen] = '\\';
XSTRNCPY(ctx->name + pathLen + 1,
ctx->FindFileData.cFileName,
IntimeFilename(ctx),
MAX_FILENAME_SZ - pathLen - 1);
if (name)
*name = ctx->name;
@@ -758,7 +758,7 @@ void wc_ReadDirClose(ReadDirCtx* ctx)
}
#elif defined(INTIME_RTOS)
FindRtFileClose(&ctx->FindFileData);
IntimeFindClose(&ctx->FindFileData);
#elif defined(WOLFSSL_ZEPHYR)
if (ctx->dirp) {

View File

@@ -699,6 +699,16 @@ WOLFSSL_API int wolfCrypt_Cleanup(void);
#define XSTAT _stat
#define XS_ISREG(s) (s & _S_IFREG)
#define SEPARATOR_CHAR ';'
#elif defined(INTIME_RTOS)
#include <sys/stat.h>
#define XSTAT _stat64
#define XS_ISREG(s) S_ISREG(s)
#define SEPARATOR_CHAR ';'
#define XWRITE write
#define XREAD read
#define XCLOSE close
#elif defined(WOLFSSL_ZEPHYR)
#define XSTAT fs_stat
#define XS_ISREG(s) (s == FS_DIR_ENTRY_FILE)
@@ -765,7 +775,23 @@ WOLFSSL_API int wolfCrypt_Cleanup(void);
struct M2MB_DIRENT* entry;
struct M2MB_STAT s;
#elif defined(INTIME_RTOS)
FIND_FILE_DATA FindFileData;
struct stat64 s;
#if defined(INTIMEVER) && INTIMEVER > 0x0600
FIND_FILE_DATA FindFileData;
#define IntimeFindFirst(name, data) FindFirstRtFile(name, data, 0)
#define IntimeFindNext(data) FindNextRtFile(data)
#define IntimeFindClose(data) FindRtFileClose(data)
#define IntimeFilename(ctx) ctx->FindFileData.cFileName
#define IntimeNormalFile(ctx) (ctx->FindFileData.dwFileAttributes \
& FILE_ATTR_NORMAL)
#else
struct _find64 FindFileData;
#define IntimeFindFirst(name, data) _findfirst64(name, data)
#define IntimeFindNext(data) _findnext64(data)
#define IntimeFindClose(data) _findclose64(data)
#define IntimeFilename(ctx) ctx->FindFileData.f_filename
#define IntimeNormalFile(ctx) (0 == wc_FileExists(IntimeFilename(ctx)))
#endif
#else
struct dirent* entry;
DIR* dir;