mailbox: bcm-pdc: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing with scnprintf(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
This commit is contained in:
parent
223a83bdcc
commit
38a5456a6d
@ -436,33 +436,33 @@ static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
|
|||||||
|
|
||||||
pdcs = filp->private_data;
|
pdcs = filp->private_data;
|
||||||
out_offset = 0;
|
out_offset = 0;
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"SPU %u stats:\n", pdcs->pdc_idx);
|
"SPU %u stats:\n", pdcs->pdc_idx);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"PDC requests....................%u\n",
|
"PDC requests....................%u\n",
|
||||||
pdcs->pdc_requests);
|
pdcs->pdc_requests);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"PDC responses...................%u\n",
|
"PDC responses...................%u\n",
|
||||||
pdcs->pdc_replies);
|
pdcs->pdc_replies);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"Tx not done.....................%u\n",
|
"Tx not done.....................%u\n",
|
||||||
pdcs->last_tx_not_done);
|
pdcs->last_tx_not_done);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"Tx ring full....................%u\n",
|
"Tx ring full....................%u\n",
|
||||||
pdcs->tx_ring_full);
|
pdcs->tx_ring_full);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"Rx ring full....................%u\n",
|
"Rx ring full....................%u\n",
|
||||||
pdcs->rx_ring_full);
|
pdcs->rx_ring_full);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"Tx desc write fail. Ring full...%u\n",
|
"Tx desc write fail. Ring full...%u\n",
|
||||||
pdcs->txnobuf);
|
pdcs->txnobuf);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"Rx desc write fail. Ring full...%u\n",
|
"Rx desc write fail. Ring full...%u\n",
|
||||||
pdcs->rxnobuf);
|
pdcs->rxnobuf);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"Receive overflow................%u\n",
|
"Receive overflow................%u\n",
|
||||||
pdcs->rx_oflow);
|
pdcs->rx_oflow);
|
||||||
out_offset += snprintf(buf + out_offset, out_count - out_offset,
|
out_offset += scnprintf(buf + out_offset, out_count - out_offset,
|
||||||
"Num frags in rx ring............%u\n",
|
"Num frags in rx ring............%u\n",
|
||||||
NRXDACTIVE(pdcs->rxin, pdcs->last_rx_curr,
|
NRXDACTIVE(pdcs->rxin, pdcs->last_rx_curr,
|
||||||
pdcs->nrxpost));
|
pdcs->nrxpost));
|
||||||
|
Loading…
Reference in New Issue
Block a user