From d87be87d96d7a32b6e2231a7769dfcd4fb28283e Mon Sep 17 00:00:00 2001 From: wargio Date: Mon, 27 Jun 2022 23:44:13 +0200 Subject: [PATCH 1/2] fixed cabd.c:1403:66: runtime error: left shift of 156 by 24 places cannot be represented in type int --- libmspack/mspack/cabd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libmspack/mspack/cabd.c b/libmspack/mspack/cabd.c index 96eac41..e26d453 100644 --- a/libmspack/mspack/cabd.c +++ b/libmspack/mspack/cabd.c @@ -1400,7 +1400,11 @@ static unsigned int cabd_checksum(unsigned char *data, unsigned int bytes, unsigned int len, ul = 0; for (len = bytes >> 2; len--; data += 4) { - cksum ^= ((data[0]) | (data[1]<<8) | (data[2]<<16) | (data[3]<<24)); + unsigned int byte0 = data[0]; + unsigned int byte1 = ((unsigned int)data[1]) << 8; + unsigned int byte2 = ((unsigned int)data[2]) << 16; + unsigned int byte3 = ((unsigned int)data[3]) << 24; + cksum ^= (byte0 | byte1 | byte2 | byte3); } switch (bytes & 3) { From d531c6b52831d769feb3ec980aacd206a0b2246b Mon Sep 17 00:00:00 2001 From: wargio Date: Mon, 27 Jun 2022 23:44:52 +0200 Subject: [PATCH 2/2] fixed chmd.c:1139:10: error: "length" may be used uninitialized in this function --- libmspack/mspack/chmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libmspack/mspack/chmd.c b/libmspack/mspack/chmd.c index f6ba3dd..9710910 100644 --- a/libmspack/mspack/chmd.c +++ b/libmspack/mspack/chmd.c @@ -1035,11 +1035,11 @@ static int chmd_sys_write(struct mspack_file *file, void *buffer, int bytes) { static int chmd_init_decomp(struct mschm_decompressor_p *self, struct mschmd_file *file) { - int window_size, window_bits, reset_interval, entry, err; + int window_size = 0, window_bits = 0, reset_interval = 0, entry = 0, err = 0; struct mspack_system *sys = self->system; - struct mschmd_sec_mscompressed *sec; - unsigned char *data; - off_t length, offset; + struct mschmd_sec_mscompressed *sec = NULL; + unsigned char *data = NULL; + off_t length = 0, offset = 0; sec = (struct mschmd_sec_mscompressed *) file->section;