From: linzhecheng <linzhecheng@huawei.com>
To: qemu-devel@nongnu.org
Cc: famz@redhat.com, pbonzini@redhat.com, wangxinxin.wang@huawei.com,
linzhecheng <linzhecheng@huawei.com>
Subject: [Qemu-devel] [PATCH] scsi: handle the special parameters
Date: Mon, 15 Jan 2018 12:16:48 +0800 [thread overview]
Message-ID: <20180115041648.33740-1-linzhecheng@huawei.com> (raw)
scsi_disk_emulate_command calls
scsi_build_sense(NULL, 0, outbuf, r->buflen,
(req->cmd.buf[1] & 1) == 0);
But scsi_convert_sense doesn't handle the case when in_buf is NULL
or in_len is 0, which will lead to segfault.
Signed-off-by: linzhecheng <linzhecheng@huawei.com>
---
scsi/utils.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scsi/utils.c b/scsi/utils.c
index ddae650a99..b769e80c12 100644
--- a/scsi/utils.c
+++ b/scsi/utils.c
@@ -322,6 +322,10 @@ int scsi_convert_sense(uint8_t *in_buf, int in_len,
SCSISense sense;
bool fixed_in;
+ if (!in_buf || !in_len) {
+ return 0;
+ }
+
fixed_in = (in_buf[0] & 2) == 0;
if (in_len && fixed == fixed_in) {
memcpy(buf, in_buf, MIN(len, in_len));
--
2.12.2.windows.2
next reply other threads:[~2018-01-15 4:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 4:16 linzhecheng [this message]
2018-01-15 9:29 ` [Qemu-devel] [PATCH] scsi: handle the special parameters 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=20180115041648.33740-1-linzhecheng@huawei.com \
--to=linzhecheng@huawei.com \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wangxinxin.wang@huawei.com \
/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).