From owner-svn-src-head@freebsd.org Fri Jul 27 07:05:51 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 453851062CA1; Fri, 27 Jul 2018 07:05:51 +0000 (UTC) (envelope-from daichi@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E6DD588C19; Fri, 27 Jul 2018 07:05:50 +0000 (UTC) (envelope-from daichi@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BFF5114AAA; Fri, 27 Jul 2018 07:05:50 +0000 (UTC) (envelope-from daichi@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6R75ovE064165; Fri, 27 Jul 2018 07:05:50 GMT (envelope-from daichi@FreeBSD.org) Received: (from daichi@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6R75oRd064164; Fri, 27 Jul 2018 07:05:50 GMT (envelope-from daichi@FreeBSD.org) Message-Id: <201807270705.w6R75oRd064164@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: daichi set sender to daichi@FreeBSD.org using -f From: Daichi GOTO Date: Fri, 27 Jul 2018 07:05:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336756 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: daichi X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 336756 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2018 07:05:51 -0000 Author: daichi Date: Fri Jul 27 07:05:50 2018 New Revision: 336756 URL: https://svnweb.freebsd.org/changeset/base/336756 Log: top(1): fix a buffer overflow copying states to display while they were incremented - fix an AddressSanitizer error Submitted by: devnexen@gmail.com Reviewed by: eadler Approved by: gnn (mentor) Differential Revision: https://reviews.freebsd.org/D16183 Modified: head/usr.bin/top/display.c Modified: head/usr.bin/top/display.c ============================================================================== --- head/usr.bin/top/display.c Fri Jul 27 05:40:03 2018 (r336755) +++ head/usr.bin/top/display.c Fri Jul 27 07:05:50 2018 (r336756) @@ -420,6 +420,7 @@ i_cpustates(int *states) int value; const char * const *names; const char *thisname; + int *hstates = states; int cpu; for (cpu = 0; cpu < num_cpus; cpu++) { @@ -453,6 +454,7 @@ for (cpu = 0; cpu < num_cpus; cpu++) { } /* copy over values into "last" array */ + states = hstates; memcpy(lcpustates, states, num_cpustates * sizeof(int) * num_cpus); } @@ -462,6 +464,7 @@ u_cpustates(int *states) int value; const char * const *names; const char *thisname; + int *hstates = states; int *lp; int *colp; int cpu; @@ -504,6 +507,8 @@ for (cpu = 0; cpu < num_cpus; cpu++) { colp++; } } + + states = hstates; } void