From: Lidong Chen <lidong.chen@oracle.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, berrange@redhat.com, liq3ea@gmail.com,
f4bug@amsat.org, armbru@redhat.com, lidong.chen@oracle.com,
darren.kenny@oracle.com, liran.alon@oracle.com,
marcandre.lureau@gmail.com, amarkovic@wavecomp.com,
pbonzini@redhat.com, philmd@redhat.com
Subject: [Qemu-devel] [Qemu-devel PATCH v3 1/2] sd: Fix out-of-bounds assertions
Date: Wed, 19 Jun 2019 15:14:46 -0400 [thread overview]
Message-ID: <6b19cb7359a10a6bedc3ea0fce22fed3ef93c102.1560806687.git.lidong.chen@oracle.com> (raw)
In-Reply-To: <cover.1560806687.git.lidong.chen@oracle.com>
In-Reply-To: <cover.1560806687.git.lidong.chen@oracle.com>
Due to an off-by-one error, the assert statements allow an
out-of-bound array access.
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Liam Merwick <liam.merwick@oracle.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
---
hw/sd/sd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index aaab15f..818f86c 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -144,7 +144,7 @@ static const char *sd_state_name(enum SDCardStates state)
if (state == sd_inactive_state) {
return "inactive";
}
- assert(state <= ARRAY_SIZE(state_name));
+ assert(state < ARRAY_SIZE(state_name));
return state_name[state];
}
@@ -165,7 +165,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp)
if (rsp == sd_r1b) {
rsp = sd_r1;
}
- assert(rsp <= ARRAY_SIZE(response_name));
+ assert(rsp < ARRAY_SIZE(response_name));
return response_name[rsp];
}
--
1.8.3.1
next prev parent reply other threads:[~2019-06-19 19:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 19:14 [Qemu-devel] [Qemu-devel PATCH v3 0/2] fix incorrect assertions in sd and main-loop Lidong Chen
2019-06-19 19:14 ` Lidong Chen [this message]
2019-06-19 19:14 ` [Qemu-devel] [Qemu-devel PATCH v3 2/2] util/main-loop: Fix incorrect assertion Lidong Chen
2019-06-20 8:06 ` [Qemu-devel] [Qemu-devel PATCH v3 0/2] fix incorrect assertions in sd and main-loop Philippe Mathieu-Daudé
2019-06-20 8:19 ` Paolo Bonzini
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=6b19cb7359a10a6bedc3ea0fce22fed3ef93c102.1560806687.git.lidong.chen@oracle.com \
--to=lidong.chen@oracle.com \
--cc=amarkovic@wavecomp.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=darren.kenny@oracle.com \
--cc=f4bug@amsat.org \
--cc=liq3ea@gmail.com \
--cc=liran.alon@oracle.com \
--cc=marcandre.lureau@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.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).