From nobody Mon Nov 01 23:59:12 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 278681820CB1; Mon, 1 Nov 2021 23:59:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hjqkn0Yzgz4WQq; Mon, 1 Nov 2021 23:59:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E31931AC16; Mon, 1 Nov 2021 23:59:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A1NxCfE071902; Mon, 1 Nov 2021 23:59:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1NxCw6071901; Mon, 1 Nov 2021 23:59:12 GMT (envelope-from git) Date: Mon, 1 Nov 2021 23:59:12 GMT Message-Id: <202111012359.1A1NxCw6071901@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 932c2667d9bc - main - systat: fix stack overflow when running -iostat List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 932c2667d9bca62ad5f03757775ebe8aa743cfd8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=932c2667d9bca62ad5f03757775ebe8aa743cfd8 commit 932c2667d9bca62ad5f03757775ebe8aa743cfd8 Author: Mateusz Guzik AuthorDate: 2021-11-01 23:55:47 +0000 Commit: Mateusz Guzik CommitDate: 2021-11-01 23:57:27 +0000 systat: fix stack overflow when running -iostat The new buffer is arbitrarily sized to likely "big enough". Sponsored by: Rubicon Communications, LLC ("Netgate") --- usr.bin/systat/iostat.c | 8 ++++---- 1 file 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);