Update WFSEEK call sites that may misinterpret return value in Harmony/Nucleus builds

pull/1157/head
Ruby Martin 2026-08-06 11:31:27 -06:00 committed by John Safranek
parent bf5a8015e2
commit 2a30f48772
7 changed files with 19 additions and 12 deletions

View File

@ -89,7 +89,7 @@ static int load_der_file(const char* filename, byte** out, word32* outSz)
if (ret != 0 || file == WBADFILE)
return -1;
if (WFSEEK(NULL, file, 0, WSEEK_END) != 0) {
if (!WFSEEK_SUCCESS(WFSEEK(NULL, file, 0, WSEEK_END))) {
WFCLOSE(NULL, file);
return -1;
}

View File

@ -304,7 +304,7 @@ static int load_der_file(const char* filename, byte** out, word32* outSz,
if (ret != 0 || file == WBADFILE)
return -1;
if (WFSEEK(NULL, file, 0, WSEEK_END) != 0) {
if (!WFSEEK_SUCCESS(WFSEEK(NULL, file, 0, WSEEK_END))) {
WFCLOSE(NULL, file);
return -1;
}

View File

@ -129,10 +129,10 @@ int wfopen(WFILE** f, const char* filename, const char* mode)
int wPwrite(WFD fd, unsigned char* buf, unsigned int sz,
const unsigned int* shortOffset)
{
int ret;
int ret = -1;
ret = (int)WFSEEK(NULL, &fd, shortOffset[0], SYS_FS_SEEK_SET);
if (ret != -1) {
if (WFSEEK_SUCCESS(WFSEEK(
NULL, &fd, shortOffset[0], SYS_FS_SEEK_SET))) {
ret = (int)WFWRITE(NULL, buf, 1, sz, &fd);
}
@ -142,10 +142,10 @@ int wfopen(WFILE** f, const char* filename, const char* mode)
int wPread(WFD fd, unsigned char* buf, unsigned int sz,
const unsigned int* shortOffset)
{
int ret;
int ret = -1;
ret = (int)WFSEEK(NULL, &fd, shortOffset[0], SYS_FS_SEEK_SET);
if (ret != -1)
if (WFSEEK_SUCCESS(WFSEEK(
NULL, &fd, shortOffset[0], SYS_FS_SEEK_SET)))
ret = (int)WFREAD(NULL, buf, 1, sz, &fd);
return ret;

View File

@ -2644,7 +2644,7 @@ static int ReadFileIntoBuffer(const char* name, byte** out, word32* outSz,
if (ret != 0 || file == WBADFILE) return WS_BAD_FILE_E;
#endif
if (WFSEEK(NULL, file, 0, WSEEK_END) != 0) {
if (!WFSEEK_SUCCESS(WFSEEK(NULL, file, 0, WSEEK_END))) {
WFCLOSE(NULL, file);
return WS_BAD_FILE_E;
}

View File

@ -10053,7 +10053,8 @@ int wolfSSH_SFTP_Put(WOLFSSH* ssh, char* from, char* to, byte resume,
#if SIZEOF_OFF_T == 8
offset = (((word64)state->pOfst[1]) << 32) | offset;
#endif
if (WFSEEK(ssh->fs, state->fl, offset, 0) != 0) {
if (!WFSEEK_SUCCESS(WFSEEK(
ssh->fs, state->fl, offset, 0))) {
WLOG(WS_LOG_SFTP, "Unable to seek input file");
ssh->error = WS_BAD_FILE_E;
ret = WS_FATAL_ERROR;

View File

@ -182,7 +182,10 @@ static int load_file(const char* fileName, byte* buf, word32* bufSz)
if (WFOPEN(NULL, &file, fileName, "rb") != 0)
return 0;
WFSEEK(NULL, file, 0, WSEEK_END);
if (!WFSEEK_SUCCESS(WFSEEK(NULL, file, 0, WSEEK_END))) {
WFCLOSE(NULL, file);
return 0;
}
fileSz = (word32)WFTELL(NULL, file);
WREWIND(NULL, file);

View File

@ -472,7 +472,10 @@ static word32 LoadFileBuffer(const char* path, byte* buf, word32 bufSz)
if (WFOPEN(NULL, &file, path, "rb") != 0 || file == WBADFILE) {
return 0;
}
WFSEEK(NULL, file, 0, WSEEK_END);
if (!WFSEEK_SUCCESS(WFSEEK(NULL, file, 0, WSEEK_END))) {
WFCLOSE(NULL, file);
return 0;
}
fileSz = WFTELL(NULL, file);
WREWIND(NULL, file);