mirror of https://github.com/wolfSSL/wolfssh.git
Update WFSEEK call sites that may misinterpret return value in Harmony/Nucleus builds
parent
bf5a8015e2
commit
2a30f48772
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
12
src/port.c
12
src/port.c
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue