aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-11-01 23:55:47 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-11-01 23:57:27 +0000
commit932c2667d9bca62ad5f03757775ebe8aa743cfd8 (patch)
treea21cc3512975e56c647eb909f77d44a514af92c0
parent6d88f9fed6a2aa1ffd2c856d246209f24b7dbea0 (diff)
downloadsrc-932c2667d9bca62ad5f03757775ebe8aa743cfd8.tar.gz
src-932c2667d9bca62ad5f03757775ebe8aa743cfd8.zip
systat: fix stack overflow when running -iostat
The new buffer is arbitrarily sized to likely "big enough". Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r--usr.bin/systat/iostat.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c
index 8767a046d81a..e3d577507e08 100644
--- a/usr.bin/systat/iostat.c
+++ b/usr.bin/systat/iostat.c
@@ -185,7 +185,7 @@ static int
numlabels(int row)
{
int i, _col, regions, ndrives;
- char tmpstr[10];
+ char tmpstr[32];
#define COLWIDTH 17
#define DRIVESPERLINE ((getmaxx(wnd) - 1 - INSET) / COLWIDTH)
@@ -211,7 +211,7 @@ numlabels(int row)
if (row > getmaxy(wnd) - 1 - (linesperregion + 1))
break;
}
- sprintf(tmpstr, "%s%d", dev_select[i].device_name,
+ snprintf(tmpstr, sizeof(tmpstr), "%s%d", dev_select[i].device_name,
dev_select[i].unit_number);
mvwaddstr(wnd, row, _col + 4, tmpstr);
mvwaddstr(wnd, row + 1, _col, " KB/t tps MB/s ");
@@ -226,7 +226,7 @@ static int
barlabels(int row)
{
int i;
- char tmpstr[10];
+ char tmpstr[32];
mvwaddstr(wnd, row++, INSET,
"/0% /10 /20 /30 /40 /50 /60 /70 /80 /90 /100");
@@ -235,7 +235,7 @@ barlabels(int row)
if (dev_select[i].selected) {
if (row > getmaxy(wnd) - 1 - linesperregion)
break;
- sprintf(tmpstr, "%s%d", dev_select[i].device_name,
+ snprintf(tmpstr, sizeof(tmpstr), "%s%d", dev_select[i].device_name,
dev_select[i].unit_number);
mvwprintw(wnd, row++, 0, "%-5.5s MB/s|",
tmpstr);