Skip to content

Commit

Permalink
Merge pull request wolfSSL#7627 from douzzer/20240606-clang-tidy-and-…
Browse files Browse the repository at this point in the history
…mingw-fixes

20240606-clang-tidy-and-mingw-fixes
  • Loading branch information
SparkiDev authored and jefferyq2 committed Jun 9, 2024
1 parent 67d037e commit af3364b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
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)
ret = (int)XREAD(bio->num, buf, (size_t)len);
#else
Expand Down Expand Up @@ -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);
}
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)
ret = (int)XWRITE(bio->num, data, (size_t)len);
#else
Expand Down Expand Up @@ -1617,7 +1617,12 @@ int wolfSSL_BIO_write_filename(WOLFSSL_BIO *bio, char *name)
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) {
return WOLFSSL_FAILURE;
}
Expand Down
11 changes: 10 additions & 1 deletion src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23701,9 +23701,18 @@ const char* wolfSSL_RAND_file_name(char* fname, unsigned long len)
const char ap[] = "/.rnd";

WOLFSSL_MSG("Environment variable RANDFILE not set");

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");
return NULL;
#endif
}

if (len > XSTRLEN(rt) + XSTRLEN(ap)) {
Expand All @@ -23713,7 +23722,7 @@ const char* wolfSSL_RAND_file_name(char* fname, unsigned long len)
return fname;
}
else {
WOLFSSL_MSG("HOME too large for buffer");
WOLFSSL_MSG("Path too large for buffer");
return NULL;
}
}
Expand Down
4 changes: 2 additions & 2 deletions wolfcrypt/src/port/riscv/riscv-64-aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ static void wc_aes_ctr_encrypt_asm(Aes* aes, byte* out, const byte* in,
* @param [in] sz Number of bytes to encrypt.
* @return 0 on success.
* @return BAD_FUNC_ARG when aes, out or in is NULL.
* @return BAD_FUNC_ARG when key size in AES object is not supported.
* @return BAD_FUNC_ARG when key size in AES object is not supported.
*/
int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
Expand Down Expand Up @@ -4231,7 +4231,7 @@ static WC_INLINE void IncrementAesCounter(byte* inOutCtr)
* @param [in] sz Number of bytes to encrypt.
* @return 0 on success.
* @return BAD_FUNC_ARG when aes, out or in is NULL.
* @return BAD_FUNC_ARG when key size in AES object is not supported.
* @return BAD_FUNC_ARG when key size in AES object is not supported.
*/
int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
Expand Down
4 changes: 2 additions & 2 deletions wolfcrypt/src/wc_kyber_poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -2785,8 +2785,8 @@ void kyber_decompress_5(sword16* p, const unsigned char* b)
* @param [in] j Index of bit in byte.
*/
#define FROM_MSG_BIT(p, msg, i, j) \
(p)[8 * (i) + (j)] = (((sword16)0 - (sword16)(((msg)[i] >> (j)) & 1)) ^ \
kyber_opt_blocker) & KYBER_Q_1_HALF
((p)[8 * (i) + (j)] = (((sword16)0 - (sword16)(((msg)[i] >> (j)) & 1)) ^ \
kyber_opt_blocker) & KYBER_Q_1_HALF)

/* Convert message to polynomial.
*
Expand Down
4 changes: 4 additions & 0 deletions wolfssl/wolfcrypt/wc_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,16 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
#if !defined(NO_WOLFSSL_DIR)\
&& !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
#if defined(USE_WINDOWS_API)
#include <io.h>
#include <sys/stat.h>
#ifndef XSTAT
#define XSTAT _stat
#endif
#define XS_ISREG(s) (s & _S_IFREG)
#define SEPARATOR_CHAR ';'
#define XWRITE _write
#define XREAD _read
#define XALTHOMEVARNAME "USERPROFILE"

#elif defined(ARDUINO)
#ifndef XSTAT
Expand Down

0 comments on commit af3364b

Please sign in to comment.