]> Git Repo - qemu.git/commitdiff
net: mipsnet: check packet length against buffer
authorPrasad J Pandit <[email protected]>
Thu, 7 Apr 2016 10:26:02 +0000 (15:56 +0530)
committerJason Wang <[email protected]>
Wed, 25 May 2016 07:46:07 +0000 (15:46 +0800)
When receiving packets over MIPSnet network device, it uses
receive buffer of size 1514 bytes. In case the controller
accepts large(MTU) packets, it could lead to memory corruption.
Add check to avoid it.

Reported by: Oleksandr Bazhaniuk <[email protected]>
Signed-off-by: Prasad J Pandit <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
hw/net/mipsnet.c

index 740cd98ff1fdc357e4565aa5bd5321a695ebe0d0..cf8b8236df8045023ed1d475b5ea05c2c22508e6 100644 (file)
@@ -83,6 +83,9 @@ static ssize_t mipsnet_receive(NetClientState *nc, const uint8_t *buf, size_t si
     if (!mipsnet_can_receive(nc))
         return 0;
 
+    if (size >= sizeof(s->rx_buffer)) {
+        return 0;
+    }
     s->busy = 1;
 
     /* Just accept everything. */
This page took 0.026261 seconds and 4 git commands to generate.