aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2016-10-14 03:34:18 -0400
committerJon Mason <jdmason@kudzu.us>2016-11-13 16:48:30 -0500
commit819baf885953b588b63bef28e5598daf9ed4ddf9 (patch)
treec4c576acfae821524f886b7f12841f9168ffa6ff
parent25ea9f2bf5f76082da919f2a91ea8d920932c1da (diff)
ntb_perf: potential info leak in debugfs
This is a static checker warning, not something I'm desperately concerned about. But snprintf() returns the number of bytes that would have been copied if there were space. We really care about the number of bytes that actually were copied so we should use scnprintf() instead. It probably won't overrun, and in that case we may as well just use sprintf() but these sorts of things make static checkers and code reviewers happier. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
-rw-r--r--drivers/ntb/test/ntb_perf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index e065b695200d..e75d4fdc0866 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -589,7 +589,7 @@ static ssize_t debugfs_run_read(struct file *filp, char __user *ubuf,
589 return -ENOMEM; 589 return -ENOMEM;
590 590
591 if (mutex_is_locked(&perf->run_mutex)) { 591 if (mutex_is_locked(&perf->run_mutex)) {
592 out_off = snprintf(buf, 64, "running\n"); 592 out_off = scnprintf(buf, 64, "running\n");
593 goto read_from_buf; 593 goto read_from_buf;
594 } 594 }
595 595
@@ -600,14 +600,14 @@ static ssize_t debugfs_run_read(struct file *filp, char __user *ubuf,
600 break; 600 break;
601 601
602 if (pctx->status) { 602 if (pctx->status) {
603 out_off += snprintf(buf + out_off, 1024 - out_off, 603 out_off += scnprintf(buf + out_off, 1024 - out_off,
604 "%d: error %d\n", i, 604 "%d: error %d\n", i,
605 pctx->status); 605 pctx->status);
606 continue; 606 continue;
607 } 607 }
608 608
609 rate = div64_u64(pctx->copied, pctx->diff_us); 609 rate = div64_u64(pctx->copied, pctx->diff_us);
610 out_off += snprintf(buf + out_off, 1024 - out_off, 610 out_off += scnprintf(buf + out_off, 1024 - out_off,
611 "%d: copied %llu bytes in %llu usecs, %llu MBytes/s\n", 611 "%d: copied %llu bytes in %llu usecs, %llu MBytes/s\n",
612 i, pctx->copied, pctx->diff_us, rate); 612 i, pctx->copied, pctx->diff_us, rate);
613 } 613 }