mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 710968 - Updater incorrectly checks fread() retval. r=bbondy
This commit is contained in:
parent
de11006829
commit
87eda9a7cd
@ -103,18 +103,15 @@ MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile,
|
||||
size_t r = header->cblen + header->difflen + header->extralen;
|
||||
unsigned char *wb = buf;
|
||||
while (r) {
|
||||
size_t c = fread(wb, 1, (r > SSIZE_MAX) ? SSIZE_MAX : r, patchFile);
|
||||
if (c < 0) {
|
||||
const size_t count = (r > SSIZE_MAX) ? SSIZE_MAX : r;
|
||||
size_t c = fread(wb, 1, count, patchFile);
|
||||
if (c != count) {
|
||||
rv = READ_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
||||
r -= c;
|
||||
|
||||
if (c == 0 && r) {
|
||||
rv = UNEXPECTED_ERROR;
|
||||
goto end;
|
||||
}
|
||||
wb += c;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1038,8 +1038,9 @@ PatchFile::LoadSourceFile(FILE* ofile)
|
||||
size_t r = header.slen;
|
||||
unsigned char *rb = buf;
|
||||
while (r) {
|
||||
size_t c = fread(rb, 1, r, ofile);
|
||||
if (c < 0) {
|
||||
const size_t count = mmin(SSIZE_MAX, r);
|
||||
size_t c = fread(rb, 1, count, ofile);
|
||||
if (c != count) {
|
||||
LOG(("LoadSourceFile: error reading destination file: " LOG_S "\n",
|
||||
mFile));
|
||||
return READ_ERROR;
|
||||
@ -1047,11 +1048,6 @@ PatchFile::LoadSourceFile(FILE* ofile)
|
||||
|
||||
r -= c;
|
||||
rb += c;
|
||||
|
||||
if (c == 0 && r) {
|
||||
LOG(("LoadSourceFile: expected %d more bytes in destination file\n", r));
|
||||
return UNEXPECTED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that the contents of the source file correspond to what we expect.
|
||||
@ -2405,17 +2401,15 @@ GetManifestContents(const NS_tchar *manifest)
|
||||
size_t r = ms.st_size;
|
||||
char *rb = mbuf;
|
||||
while (r) {
|
||||
size_t c = fread(rb, 1, mmin(SSIZE_MAX, r), mfile);
|
||||
if (c < 0) {
|
||||
const size_t count = mmin(SSIZE_MAX, r);
|
||||
size_t c = fread(rb, 1, count, mfile);
|
||||
if (c != count) {
|
||||
LOG(("GetManifestContents: error reading manifest file: " LOG_S "\n", manifest));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r -= c;
|
||||
rb += c;
|
||||
|
||||
if (c == 0 && r)
|
||||
return NULL;
|
||||
}
|
||||
mbuf[ms.st_size] = '\0';
|
||||
rb = mbuf;
|
||||
|
Loading…
Reference in New Issue
Block a user