Merge pull request #2697 from AenBleidd/verify_chunk_improvements

[client] Verify chunk improvements
This commit is contained in:
David Anderson 2018-09-20 00:37:53 -07:00 committed by GitHub
commit 0a200b2dbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -273,7 +273,7 @@ void ASYNC_VERIFY::error(int retval) {
}
int ASYNC_VERIFY::verify_chunk() {
int n;
size_t n;
unsigned char buf[BUFSIZE];
if (fip->download_gzipped) {
n = gzread(gzin, buf, BUFSIZE);
@ -287,23 +287,23 @@ int ASYNC_VERIFY::verify_chunk() {
finish();
return 1;
} else {
int m = (int)fwrite(buf, 1, n, out);
if (m != n) {
size_t m = fwrite(buf, 1, n, out);
if (m != n || ferror(out)) {
// write failed
//
error(ERR_FWRITE);
return 1;
}
md5_append(&md5_state, buf, n);
md5_append(&md5_state, buf, (int)n);
}
} else {
n = (int)fread(buf, 1, BUFSIZE, in);
if (n <= 0) {
n = fread(buf, 1, BUFSIZE, in);
if (!n || ferror(in)) {
fclose(in);
finish();
return 1;
} else {
md5_append(&md5_state, buf, n);
md5_append(&md5_state, buf, (int)n);
}
}
return 0;