Skip to content

Commit

Permalink
http: Check fread() result to avoid warning.
Browse files Browse the repository at this point in the history
This will cause the length not to match the result if it happens, but the
client should interpret that as a server error.

Also a similar error in headless.
  • Loading branch information
unknownbrackets committed Jun 17, 2018
1 parent 4a92db4 commit 6592c62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Core/WebServer.cpp
Expand Up @@ -163,7 +163,8 @@ static void RegisterDiscHandlers(http::Server *http, std::unordered_map<std::str
char *buf = new char[CHUNK_SIZE];
for (s64 pos = 0; pos < len; pos += CHUNK_SIZE) {
s64 chunklen = std::min(len - pos, (s64)CHUNK_SIZE);
fread(buf, chunklen, 1, fp);
if (fread(buf, chunklen, 1, fp) != 1)
break;
request.Out()->Push(buf, chunklen);
}
fclose(fp);
Expand Down
4 changes: 3 additions & 1 deletion headless/StubHost.cpp
Expand Up @@ -71,7 +71,9 @@ void HeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h)
FILE *bmp = File::OpenCFile(comparisonScreenshot_, "rb");
if (bmp)
{
fread(&header, sizeof(header), 1, bmp);
if (fread(&header, sizeof(header), 1, bmp) != 1) {
SendOrCollectDebugOutput("Failed to read original screenshot header.\n");
}
fclose(bmp);
}

Expand Down

0 comments on commit 6592c62

Please sign in to comment.