From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Hanna Reitz <hreitz@redhat.com>, Stefan Weil <sw@weilnetz.de>
Subject: Re: [PATCH v2 2/4] block/ssh.c: Don't double-check that characters are hex digits
Date: Tue, 8 Oct 2024 11:46:08 -0700 [thread overview]
Message-ID: <001b332a-4271-484b-872b-056cde3e9655@linaro.org> (raw)
In-Reply-To: <20241008164708.2966400-3-peter.maydell@linaro.org>
On 10/8/24 09:47, Peter Maydell wrote:
> In compare_fingerprint() we effectively check whether the characters
> in the fingerprint are valid hex digits twice: first we do so with
> qemu_isxdigit(), but then the hex2decimal() function also has a code
> path where it effectively detects an invalid digit and returns -1.
> This causes Coverity to complain because it thinks that we might use
> that -1 value in an expression where it would be an integer overflow.
>
> Avoid the double-check of hex digit validity by testing the return
> values from hex2decimal() rather than doing separate calls to
> qemu_isxdigit().
>
> Since this means we now use the illegal-character return value
> from hex2decimal(), rewrite it from "-1" to "UINT_MAX", which
> has the same effect since the return type is "unsigned" but
> looks less confusing at the callsites when we detect it with
> "c0 > 0xf".
>
> Resolves: Coverity CID 1547813
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> Reviewed-by: Kevin Wolf<kwolf@redhat.com>
> ---
> v1->v2: make hex2decimal() return UINT_MAX, not -1
> ---
> block/ssh.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2024-10-08 18:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 16:47 [PATCH v2 0/4] block: Miscellaneous minor Coverity fixes Peter Maydell
2024-10-08 16:47 ` [PATCH v2 1/4] block/gluster: Use g_autofree for string in qemu_gluster_parse_json() Peter Maydell
2024-10-08 18:44 ` Richard Henderson
2024-10-08 16:47 ` [PATCH v2 2/4] block/ssh.c: Don't double-check that characters are hex digits Peter Maydell
2024-10-08 18:46 ` Richard Henderson [this message]
2024-10-08 16:47 ` [PATCH v2 3/4] tests/qemu-iotests/211.out: Update to expect MapEntry 'compressed' field Peter Maydell
2024-10-08 16:47 ` [PATCH v2 4/4] block/vdi.c: Make SECTOR_SIZE constant 64-bits Peter Maydell
2024-10-18 13:40 ` [PATCH v2 0/4] block: Miscellaneous minor Coverity fixes Kevin Wolf
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=001b332a-4271-484b-872b-056cde3e9655@linaro.org \
--to=richard.henderson@linaro.org \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/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).