[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PATCH v3 10/25] usb-redir: Verify usbredirparser_write get
From: |
Philippe Mathieu-Daudé |
Subject: |
[qemu-s390x] [PATCH v3 10/25] usb-redir: Verify usbredirparser_write get called with positive count |
Date: |
Wed, 20 Feb 2019 02:02:17 +0100 |
The usbredirparser_write handler should never be called with a negative
size payload, return an error if this is not the case.
Now that we are sure the 'count' value is positive, make it obvious by
casting it to a size_t.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/usb/redirect.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 18a42d1938..131eae2e7e 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -285,7 +285,11 @@ static int usbredir_write(void *priv, uint8_t *data, int
count)
return 0;
}
- r = qemu_chr_fe_write(&dev->cs, data, count);
+ if (count < 0) {
+ ERROR("Illegal write count: %i\n", count);
+ return 0;
+ }
+ r = qemu_chr_fe_write(&dev->cs, data, (size_t)count);
if (r < count) {
if (!dev->watch) {
dev->watch = qemu_chr_fe_add_watch(&dev->cs, G_IO_OUT | G_IO_HUP,
--
2.20.1
- Re: [qemu-s390x] [PATCH v3 02/25] chardev: Assert IOCanReadHandler can not be negative, (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é <=
- [qemu-s390x] [PATCH v3 23/25] hw/ipmi: Assert outlen > outpos, Philippe Mathieu-Daudé, 2019/02/19
- [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