[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 47/97] pcnet: fix possible buffer overflow
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 47/97] pcnet: fix possible buffer overflow |
Date: |
Mon, 1 Apr 2019 15:59:21 -0500 |
From: Jason Wang <address@hidden>
In pcnet_receive(), we try to assign size_ to size which converts from
size_t to integer. This will cause troubles when size_ is greater
INT_MAX, this will lead a negative value in size and it can then pass
the check of size < MIN_BUF_SIZE which may lead out of bound access
for both buf and buf1.
Fixing by converting the type of size to size_t.
CC: address@hidden
Reported-by: Daniel Shapira <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
(cherry picked from commit b1d80d12c5f7ff081bb80ab4f4241d4248691192)
Signed-off-by: Michael Roth <address@hidden>
---
hw/net/pcnet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index 0c44554168..d9ba04bdfc 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -988,14 +988,14 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t
*buf, size_t size_)
uint8_t buf1[60];
int remaining;
int crc_err = 0;
- int size = size_;
+ size_t size = size_;
if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size ||
(CSR_LOOP(s) && !s->looptest)) {
return -1;
}
#ifdef PCNET_DEBUG
- printf("pcnet_receive size=%d\n", size);
+ printf("pcnet_receive size=%zu\n", size);
#endif
/* if too small buffer, then expand it */
--
2.17.1
- [Qemu-stable] [PATCH 24/97] vnc: fix memleak of the "vnc-worker-output" name, (continued)
- [Qemu-stable] [PATCH 24/97] vnc: fix memleak of the "vnc-worker-output" name, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 87/97] block: Fix invalidate_cache error path for parent activation, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 06/97] target/arm: Fix sign-extension in sve do_ldr/do_str, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 72/97] mirror: fix dead-lock, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 42/97] block/rbd: add iotest for rbd legacy keyvalue filename parsing, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 15/97] target/arm: Use fp_status_fp16 for do_fmpa_zpzzz_h, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 90/97] slirp: check sscanf result when emulating ident, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 84/97] tpm: use loop iterator to set sts data field, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 83/97] tpm: Zero-init structure to avoid uninitialized variables in valgrind log, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 44/97] target/arm: Fix cpu_get_tb_cpu_state() for non-SVE CPUs, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 47/97] pcnet: fix possible buffer overflow,
Michael Roth <=
- [Qemu-stable] [PATCH 92/97] bitmap: Update count after a merge, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 25/97] i386: Disable TOPOEXT by default on "-cpu host", Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 62/97] fdc: fix segfault in fdctrl_stop_transfer() when DMA is disabled, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 19/97] qemu-img: fix regression copying secrets during convert, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 26/97] block: for jobs, do not clear user_paused until after the resume, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 67/97] i2c: Move typedef of bitbang_i2c_interface to i2c.h, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 88/97] acpi: Make TPM 2.0 with TIS available as MSFT0101, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 03/97] target/arm: Reorganize SVE WHILE, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 49/97] virt: Suppress external aborts on virt-2.10 and earlier, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 63/97] qemu-img: Fix typo, Michael Roth, 2019/04/01