diff --git a/apps/wolfssh/common.c b/apps/wolfssh/common.c index 2d6e7693..f5e1883c 100644 --- a/apps/wolfssh/common.c +++ b/apps/wolfssh/common.c @@ -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; } diff --git a/examples/client/common.c b/examples/client/common.c index 7de8133f..d8a6e9b3 100644 --- a/examples/client/common.c +++ b/examples/client/common.c @@ -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; } diff --git a/src/port.c b/src/port.c index 8c1255a6..12660346 100644 --- a/src/port.c +++ b/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; diff --git a/src/ssh.c b/src/ssh.c index 8bd609fc..e28f152e 100644 --- a/src/ssh.c +++ b/src/ssh.c @@ -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; } diff --git a/src/wolfsftp.c b/src/wolfsftp.c index 1ec9d6e5..1e2c1e1b 100644 --- a/src/wolfsftp.c +++ b/src/wolfsftp.c @@ -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; diff --git a/tests/auth.c b/tests/auth.c index 2f3c0741..953b3574 100644 --- a/tests/auth.c +++ b/tests/auth.c @@ -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); diff --git a/tests/regress.c b/tests/regress.c index ca80a4f5..c66a84a5 100644 --- a/tests/regress.c +++ b/tests/regress.c @@ -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);