Skip to content

Commit

Permalink
ath9k: snprintf() returns largish values
Browse files Browse the repository at this point in the history
The snprintf() function returns the number of characters that would have
been written (not counting the NUL character on the end).  It could
potentially be larger than the size of the buffer.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Dan Carpenter authored and John W. Linville committed Jul 26, 2010
1 parent 929ebd3 commit 9746010
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/net/wireless/ath/ath9k/htc_drv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,9 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
len += snprintf(buf + len, sizeof(buf) - len,
"%19s : %10u\n", "TX Rate", priv->debug.txrate);

if (len > sizeof(buf))
len = sizeof(buf);

return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

Expand Down Expand Up @@ -569,6 +572,9 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
"%20s : %10u\n", "VO queued",
priv->debug.tx_stats.queue_stats[WME_AC_VO]);

if (len > sizeof(buf))
len = sizeof(buf);

return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

Expand All @@ -595,6 +601,9 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
"%20s : %10u\n", "SKBs Dropped",
priv->debug.rx_stats.skb_dropped);

if (len > sizeof(buf))
len = sizeof(buf);

return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

Expand Down

0 comments on commit 9746010

Please sign in to comment.