From: Simon Horman <horms@kernel.org>
To: McLaughlin Amy <amy.mclaughlin@hubersuhner.com>
Cc: "kexec@lists.infradead.org" <kexec@lists.infradead.org>
Subject: Re: Bug report - GZ magic check always fails in uImage_gz_load
Date: Mon, 2 Dec 2024 13:05:12 +0000 [thread overview]
Message-ID: <20241202130512.GA3737@kernel.org> (raw)
In-Reply-To: <DB8P193MB0710307EC147427C3B14E24383222@DB8P193MB0710.EURP193.PROD.OUTLOOK.COM>
On Thu, Nov 21, 2024 at 02:24:47PM +0000, McLaughlin Amy wrote:
> I tried adding -Wextra to Kexec's makefile, while compiling some work by a colleague that built on the kexec source. It spotted the following:
>
> ```
> kexec/kexec-uImage.c: In function 'uImage_gz_load':
> kexec/kexec-uImage.c:160:31: warning: comparison is always true due to limited range of data type [-Wtype-limits]
> 160 | if (buf[0] != 0x1f || buf[1] != 0x8b) {
> | ^~
> ```
>
> With buf being an array of signed char, buf[1] cannot equal 0x8b without a cast, meaning that this function will always return -1 early on. Maybe representing it as an array of uint8_t/unsigned char would have been a better idea?
Hi Amy,
Yes, I agree that seems wrong and that your proposed solution sounds good.
But I do wonder if this code has been exercised. Since as you point out,
it always returns early. I'm guessing no-one is using gzipped uImages.
So perhaps we could consider a more radical approach of removing support
for those images?
In any case, could you consider sending a patch to fix the problem
you've found?
prev parent reply other threads:[~2024-12-02 13:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 14:24 Bug report - GZ magic check always fails in uImage_gz_load McLaughlin Amy
2024-12-02 13:05 ` Simon Horman [this message]
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=20241202130512.GA3737@kernel.org \
--to=horms@kernel.org \
--cc=amy.mclaughlin@hubersuhner.com \
--cc=kexec@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.