From: trix@redhat.com
To: hpa@zytor.com, alain@knaff.lu
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Tom Rix <trix@redhat.com>
Subject: [PATCH] decompress_bunzip2: fix sizeof type in start_bunzip
Date: Sun, 12 Jul 2020 05:59:52 -0700 [thread overview]
Message-ID: <20200712125952.8809-1-trix@redhat.com> (raw)
From: Tom Rix <trix@redhat.com>
clang static analysis flags this error
lib/decompress_bunzip2.c:671:13: warning: Result of 'malloc' is converted
to a pointer of type 'unsigned int', which is incompatible with sizeof
operand type 'int' [unix.MallocSizeof]
bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reviewing the bunzip_data structure, the element dbuf is type
/* Intermediate buffer and its size (in bytes) */
unsigned int *dbuf, dbufSize;
So change the type in sizeof to 'unsigned int'
Fixes: bc22c17e12c1 ("bzip2/lzma: library support for gzip, bzip2 and lzma decompression")
Signed-off-by: Tom Rix <trix@redhat.com>
---
lib/decompress_bunzip2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
index 7c4932eed748..59ab76bda7a7 100644
--- a/lib/decompress_bunzip2.c
+++ b/lib/decompress_bunzip2.c
@@ -668,7 +668,7 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, long len,
uncompressed data. Allocate intermediate buffer for block. */
bd->dbufSize = 100000*(i-BZh0);
- bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
+ bd->dbuf = large_malloc(bd->dbufSize * sizeof(unsigned int));
if (!bd->dbuf)
return RETVAL_OUT_OF_MEMORY;
return RETVAL_OK;
--
2.18.1
next reply other threads:[~2020-07-12 13:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-12 12:59 trix [this message]
2020-07-12 13:09 ` [PATCH] decompress_bunzip2: fix sizeof type in start_bunzip H. Peter Anvin
2020-07-12 15:12 ` Tom Rix
2020-07-12 21:49 ` Joe Perches
2020-07-12 22:21 ` hpa
2020-07-13 19:27 ` Tom Rix
2020-07-13 19:51 ` hpa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200712125952.8809-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=alain@knaff.lu \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).