forked from wolfSSL/wolfssl
fixes for USE_WINDOWS_API && !NO_FILESYSTEM && !NO_WOLFSSL_DIR:
* in wc_port.h, add XWRITE and XREAD definitions and include <io.h>; * in wolfSSL_BIO_read(), implement Windows support for XREAD and XWRITE; * in wolfSSL_BIO_write_filename(), add 'b' flag to XFOPEN flags; * in wolfSSL_RAND_file_name(), add support for XALTHOMEVARNAME, and add Windows definition for it to wc_port.h alongside XWRITE and XREAD. fixes test_wolfSSL_BIO, test_wolfSSL_X509_print, test_wolfSSL_RAND, test_wolfSSL_RSA_print in cross-mingw-all-crypto scenario.
This commit is contained in:
11
src/bio.c
11
src/bio.c
@ -312,7 +312,7 @@ int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len)
|
|||||||
ret = (int)XFREAD(buf, 1, (size_t)len, (XFILE)bio->ptr);
|
ret = (int)XFREAD(buf, 1, (size_t)len, (XFILE)bio->ptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR) && \
|
#if defined(XREAD) && !defined(NO_WOLFSSL_DIR) && \
|
||||||
!defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
|
!defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
|
||||||
ret = (int)XREAD(bio->num, buf, (size_t)len);
|
ret = (int)XREAD(bio->num, buf, (size_t)len);
|
||||||
#else
|
#else
|
||||||
@ -682,7 +682,7 @@ int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len)
|
|||||||
ret = (int)XFWRITE(data, 1, (size_t)len, (XFILE)bio->ptr);
|
ret = (int)XFWRITE(data, 1, (size_t)len, (XFILE)bio->ptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR) && \
|
#if defined(XWRITE) && !defined(NO_WOLFSSL_DIR) && \
|
||||||
!defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
|
!defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
|
||||||
ret = (int)XWRITE(bio->num, data, (size_t)len);
|
ret = (int)XWRITE(bio->num, data, (size_t)len);
|
||||||
#else
|
#else
|
||||||
@ -1617,7 +1617,12 @@ int wolfSSL_BIO_write_filename(WOLFSSL_BIO *bio, char *name)
|
|||||||
XFCLOSE((XFILE)bio->ptr);
|
XFCLOSE((XFILE)bio->ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bio->ptr = XFOPEN(name, "w");
|
/* 'b' flag is ignored on POSIX targets, but on Windows it assures
|
||||||
|
* inhibition of LF<->CRLF rewriting, so that there is consistency
|
||||||
|
* between the size and contents of the representation in memory and on
|
||||||
|
* disk.
|
||||||
|
*/
|
||||||
|
bio->ptr = XFOPEN(name, "wb");
|
||||||
if (((XFILE)bio->ptr) == XBADFILE) {
|
if (((XFILE)bio->ptr) == XBADFILE) {
|
||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
|
11
src/ssl.c
11
src/ssl.c
@ -23701,9 +23701,18 @@ const char* wolfSSL_RAND_file_name(char* fname, unsigned long len)
|
|||||||
const char ap[] = "/.rnd";
|
const char ap[] = "/.rnd";
|
||||||
|
|
||||||
WOLFSSL_MSG("Environment variable RANDFILE not set");
|
WOLFSSL_MSG("Environment variable RANDFILE not set");
|
||||||
|
|
||||||
if ((rt = XGETENV("HOME")) == NULL) {
|
if ((rt = XGETENV("HOME")) == NULL) {
|
||||||
|
#ifdef XALTHOMEVARNAME
|
||||||
|
if ((rt = XGETENV(XALTHOMEVARNAME)) == NULL) {
|
||||||
|
WOLFSSL_MSG("Environment variable HOME and " XALTHOMEVARNAME
|
||||||
|
" not set");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
WOLFSSL_MSG("Environment variable HOME not set");
|
WOLFSSL_MSG("Environment variable HOME not set");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > XSTRLEN(rt) + XSTRLEN(ap)) {
|
if (len > XSTRLEN(rt) + XSTRLEN(ap)) {
|
||||||
@ -23713,7 +23722,7 @@ const char* wolfSSL_RAND_file_name(char* fname, unsigned long len)
|
|||||||
return fname;
|
return fname;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WOLFSSL_MSG("HOME too large for buffer");
|
WOLFSSL_MSG("Path too large for buffer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -716,12 +716,16 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#if !defined(NO_WOLFSSL_DIR)\
|
#if !defined(NO_WOLFSSL_DIR)\
|
||||||
&& !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
|
&& !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
|
||||||
#if defined(USE_WINDOWS_API)
|
#if defined(USE_WINDOWS_API)
|
||||||
|
#include <io.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifndef XSTAT
|
#ifndef XSTAT
|
||||||
#define XSTAT _stat
|
#define XSTAT _stat
|
||||||
#endif
|
#endif
|
||||||
#define XS_ISREG(s) (s & _S_IFREG)
|
#define XS_ISREG(s) (s & _S_IFREG)
|
||||||
#define SEPARATOR_CHAR ';'
|
#define SEPARATOR_CHAR ';'
|
||||||
|
#define XWRITE _write
|
||||||
|
#define XREAD _read
|
||||||
|
#define XALTHOMEVARNAME "USERPROFILE"
|
||||||
|
|
||||||
#elif defined(ARDUINO)
|
#elif defined(ARDUINO)
|
||||||
#ifndef XSTAT
|
#ifndef XSTAT
|
||||||
|
Reference in New Issue
Block a user