]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
beceem: don't overrun user buffer on read
authorStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 1 Nov 2010 17:59:01 +0000 (13:59 -0400)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 1 Nov 2010 17:59:01 +0000 (13:59 -0400)
Serious bug in original code, if app reads 10 bytes but 20 byte msg
received memory would get overwritten.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
drivers/staging/bcm/Bcmchar.c

index 1a255609aeda6891c5a53dc2e9aae597bb980dc4..8089d19e6c1b5ff493c74ba0efe2548043d9d95b 100644 (file)
@@ -139,7 +139,7 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, l
        if(Packet)
        {
                PktLen = Packet->len;
-               if(copy_to_user(buf, Packet->data, PktLen))
+               if(copy_to_user(buf, Packet->data, min_t(size_t, PktLen, size)))
                {
                        dev_kfree_skb(Packet);
                        BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nReturning from copy to user failure \n");