Skip to content

Commit

Permalink
beceem: don't overrun user buffer on read
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Hemminger committed Nov 1, 2010
1 parent 5cf084f commit 9c5d770
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/bcm/Bcmchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 9c5d770

Please sign in to comment.