diff --git a/common/bstrlib/bstrlib.c b/common/bstrlib/bstrlib.c index 5eaada2..e44e76d 100644 --- a/common/bstrlib/bstrlib.c +++ b/common/bstrlib/bstrlib.c @@ -2399,7 +2399,10 @@ int i, c, v; v = (bl->qty - 1) * len; if ((bl->qty > 512 || len > 127) && v / len != bl->qty - 1) return NULL; /* Overflow */ - if (v > INT_MAX - c) return NULL; /* Overflow */ + if (v > INT_MAX - c) { + bstr__free (b); + return NULL; /* Overflow */ + } c += v; p = b->data = (unsigned char *) bstr__alloc (c); if (p == NULL) { @@ -2542,6 +2545,7 @@ int bssplitstrcb (struct bStream * s, const_bstring splitStr, } buff->slen = 0; } + bdestroy (buff); return BSTR_OK; } else { for (;;) { diff --git a/common/ffs.cpp b/common/ffs.cpp index c5f3c41..ed414a8 100644 --- a/common/ffs.cpp +++ b/common/ffs.cpp @@ -46,7 +46,9 @@ VOID uint32ToUint24(UINT32 size, UINT8* ffsSize) UINT32 uint24ToUint32(const UINT8* ffsSize) { - return readUnaligned((UINT32*)ffsSize) & 0x00FFFFFF; + return (UINT32) ffsSize[0] + + ((UINT32) ffsSize[1] << 8U) + + ((UINT32) ffsSize[2] << 16U); } UString guidToUString(const EFI_GUID & guid, bool convertToString) diff --git a/common/sha256.c b/common/sha256.c index c99c162..9177f45 100644 --- a/common/sha256.c +++ b/common/sha256.c @@ -90,7 +90,7 @@ static const unsigned long K[64] = { #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #endif /* compress 512-bits */ -static int sha256_compress(struct sha256_state *md, unsigned char *buf) +static void sha256_compress(struct sha256_state *md, unsigned char *buf) { uint32_t S[8], W[64], t0, t1; uint32_t t; @@ -122,7 +122,6 @@ h = t0 + t1; for (i = 0; i < 8; i++) { md->state[i] = md->state[i] + S[i]; } - return 0; } /* Initialize the hash state */ void sha256_init(struct sha256_state *md) @@ -154,8 +153,7 @@ int sha256_process(struct sha256_state *md, const unsigned char *in, return -1; while (inlen > 0) { if (md->curlen == 0 && inlen >= block_size) { - if (sha256_compress(md, (unsigned char *) in) < 0) - return -1; + sha256_compress(md, (unsigned char *) in); md->length += block_size * 8; in += block_size; inlen -= block_size; @@ -166,8 +164,7 @@ int sha256_process(struct sha256_state *md, const unsigned char *in, in += n; inlen -= n; if (md->curlen == block_size) { - if (sha256_compress(md, md->buf) < 0) - return -1; + sha256_compress(md, md->buf); md->length += 8 * block_size; md->curlen = 0; } diff --git a/common/zlib/deflate.c b/common/zlib/deflate.c index 1ec7614..909606d 100755 --- a/common/zlib/deflate.c +++ b/common/zlib/deflate.c @@ -190,8 +190,11 @@ local const config configuration_table[10] = { * prev[] will be initialized on the fly. */ #define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + do { \ + s->head[s->hash_size-1] = NIL; \ + zmemzero((Bytef *)s->head, \ + (unsigned)(s->hash_size-1)*sizeof(*s->head)); \ + } while (0) /* =========================================================================== * Slide the hash table when sliding the window down (could be avoided with 32