From 1119d773e16d4183599bf3823fd3670b3e2e341d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 15 Jan 2015 00:13:41 -0800 Subject: [PATCH] Util: Fix some warnings --- src/util/patch-ups.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/util/patch-ups.c b/src/util/patch-ups.c index 58964dbb2..f51d4cc0a 100644 --- a/src/util/patch-ups.c +++ b/src/util/patch-ups.c @@ -129,6 +129,9 @@ bool _BPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, siz if (_decodeLength(patch->vf) != outSize) { return false; } + if (inSize > SSIZE_MAX || outSize > SSIZE_MAX) { + return false; + } size_t metadataLength = _decodeLength(patch->vf); patch->vf->seek(patch->vf, metadataLength, SEEK_CUR); // Skip metadata size_t writeLocation = 0; @@ -153,7 +156,7 @@ bool _BPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, siz break; case 0x1: // TargetRead - if (patch->vf->read(patch->vf, &writeBuffer[writeLocation], length) != length) { + if (patch->vf->read(patch->vf, &writeBuffer[writeLocation], length) != (ssize_t) length) { return false; } outputChecksum = updateCrc32(outputChecksum, &writeBuffer[writeLocation], length); @@ -167,7 +170,7 @@ bool _BPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, siz } else { readSourceLocation += readOffset >> 1; } - if (readSourceLocation < 0 || readSourceLocation > inSize) { + if (readSourceLocation < 0 || readSourceLocation > (ssize_t) inSize) { return false; } memmove(&writeBuffer[writeLocation], &readBuffer[readSourceLocation], length); @@ -183,7 +186,7 @@ bool _BPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, siz } else { readTargetLocation += readOffset >> 1; } - if (readTargetLocation < 0 || readTargetLocation > outSize) { + if (readTargetLocation < 0 || readTargetLocation > (ssize_t) outSize) { return false; } for (i = 0; i < length; ++i) {