mirror of https://github.com/wolfSSL/wolfssh.git
Release v1.4.18: Release Testing Fixes
1. Fix echoserver's load_file function. Could potentially dereference null if a file size is passed in, but using a null buf to get the file's size only.pull/726/head
parent
e9ec4fd9fd
commit
dc2065719f
|
@ -1609,21 +1609,19 @@ static int load_file(const char* fileName, byte* buf, word32* bufSz)
|
|||
fileSz = (word32)WFTELL(NULL, file);
|
||||
WREWIND(NULL, file);
|
||||
|
||||
if (fileSz > *bufSz) {
|
||||
if (buf == NULL)
|
||||
*bufSz = fileSz;
|
||||
if (buf == NULL || fileSz > *bufSz) {
|
||||
*bufSz = fileSz;
|
||||
WFCLOSE(NULL, file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
readSz = (word32)WFREAD(NULL, buf, 1, fileSz, file);
|
||||
if (readSz < fileSz) {
|
||||
WFCLOSE(NULL, file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WFCLOSE(NULL, file);
|
||||
|
||||
if (readSz < fileSz) {
|
||||
fileSz = 0;
|
||||
}
|
||||
|
||||
return fileSz;
|
||||
}
|
||||
#endif /* NO_FILESYSTEM */
|
||||
|
|
Loading…
Reference in New Issue