[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PATCH v3 23/25] hw/ipmi: Assert outlen > outpos
From: |
Philippe Mathieu-Daudé |
Subject: |
[qemu-s390x] [PATCH v3 23/25] hw/ipmi: Assert outlen > outpos |
Date: |
Wed, 20 Feb 2019 02:02:30 +0100 |
A througfull audit show that all time data is added to outbuf[],
'outlen' is incremented. Then at creation and each time
continue_send() returns it pass thru check_reset which resets
'outpos', thus we always have 'outlen >= outpos'.
Also due to the check on entry, we know outlen != 0.
We can then add an assertion on 'outlen > outpos', which will
helps the next patch to safely convert 'outlen - outpos' as an
unsigned type (size_t).
Make this assertion explicit by casting 'outlen - outpos' size_t.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/ipmi/ipmi_bmc_extern.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index bf0b7ee0f5..ca61b04942 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -107,8 +107,9 @@ static void continue_send(IPMIBmcExtern *ibe)
goto check_reset;
}
send:
+ assert(ibe->outlen > ibe->outpos);
ret = qemu_chr_fe_write(&ibe->chr, ibe->outbuf + ibe->outpos,
- ibe->outlen - ibe->outpos);
+ (size_t)(ibe->outlen - ibe->outpos));
if (ret > 0) {
ibe->outpos += ret;
}
--
2.20.1
- Re: [qemu-s390x] [PATCH v3 01/25] chardev: Simplify IOWatchPoll::fd_can_read as a GSourceFunc, (continued)
- [qemu-s390x] [PATCH v3 19/25] s390/ebcdic: Use size_t to iterate over arrays, Philippe Mathieu-Daudé, 2019/02/19
- [qemu-s390x] [PATCH v3 10/25] usb-redir: Verify usbredirparser_write get called with positive count, Philippe Mathieu-Daudé, 2019/02/19
- [qemu-s390x] [PATCH v3 23/25] hw/ipmi: Assert outlen > outpos,
Philippe Mathieu-Daudé <=
- [qemu-s390x] [PATCH v3 17/25] net/filter-mirror: Use size_t, Philippe Mathieu-Daudé, 2019/02/19
- [qemu-s390x] [PATCH v3 25/25] chardev: Let qemu_chr_write[_all] use size_t, Philippe Mathieu-Daudé, 2019/02/19
[qemu-s390x] [PATCH v3 16/25] tpm: Use size_t to hold sizes, Philippe Mathieu-Daudé, 2019/02/19