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
John Safranek 2024-07-18 13:48:39 -07:00
parent e9ec4fd9fd
commit dc2065719f
1 changed files with 6 additions and 8 deletions

View File

@ -1609,21 +1609,19 @@ static int load_file(const char* fileName, byte* buf, word32* bufSz)
fileSz = (word32)WFTELL(NULL, file); fileSz = (word32)WFTELL(NULL, file);
WREWIND(NULL, file); WREWIND(NULL, file);
if (fileSz > *bufSz) { if (buf == NULL || fileSz > *bufSz) {
if (buf == NULL) *bufSz = fileSz;
*bufSz = fileSz;
WFCLOSE(NULL, file); WFCLOSE(NULL, file);
return 0; return 0;
} }
readSz = (word32)WFREAD(NULL, buf, 1, fileSz, file); readSz = (word32)WFREAD(NULL, buf, 1, fileSz, file);
if (readSz < fileSz) {
WFCLOSE(NULL, file);
return 0;
}
WFCLOSE(NULL, file); WFCLOSE(NULL, file);
if (readSz < fileSz) {
fileSz = 0;
}
return fileSz; return fileSz;
} }
#endif /* NO_FILESYSTEM */ #endif /* NO_FILESYSTEM */