From owner-svn-src-head@freebsd.org Fri Jul 6 14:49:24 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 1E731102E725 for ; Fri, 6 Jul 2018 14:49:24 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1b.ore.mailhop.org (outbound1b.ore.mailhop.org [54.200.247.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9C6DB845F0 for ; Fri, 6 Jul 2018 14:49:23 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-RoutePath: aGlwcGll X-MHO-User: c020520c-812b-11e8-8837-614b7c574d04 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound1.ore.mailhop.org (Halon) with ESMTPSA id c020520c-812b-11e8-8837-614b7c574d04; Fri, 06 Jul 2018 14:49:15 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w66EnDkv026684; Fri, 6 Jul 2018 08:49:13 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1530888553.57805.8.camel@freebsd.org> Subject: Re: svn commit: r336031 - head/usr.bin/top From: Ian Lepore To: Sean Bruno , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Fri, 06 Jul 2018 08:49:13 -0600 In-Reply-To: <201807061322.w66DMjRG084523@repo.freebsd.org> References: <201807061322.w66DMjRG084523@repo.freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 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, 06 Jul 2018 14:49:24 -0000 On Fri, 2018-07-06 at 13:22 +0000, Sean Bruno wrote: > Author: sbruno > Date: Fri Jul  6 13:22:44 2018 > New Revision: 336031 > URL: https://svnweb.freebsd.org/changeset/base/336031 > > Log: >   r336028 changed next_msg to a char * from char [] of fixed size.  Change >   2nd argument of vsnprintf() to get the strlen of next_msg so that the >   appropriate size is used. >    >   Found with gcc. >    >   /usr.bin/top/display.c: In function 'new_message': >   /usr.bin/top/display.c:963:31: error: >   argument to 'sizeof' in 'vsnprintf' call is the same expression as the >   destination; did you mean to provide an explicit length? >   [-Werror=sizeof-pointer-memaccess] >        vsnprintf(next_msg, sizeof(next_msg), msgfmt, args); >    >   Reviewed by: daichi > > Modified: >   head/usr.bin/top/display.c > > Modified: head/usr.bin/top/display.c > ============================================================================== > --- head/usr.bin/top/display.c Fri Jul  6 12:44:48 2018 (r336030) > +++ head/usr.bin/top/display.c Fri Jul  6 13:22:44 2018 (r336031) > @@ -960,7 +960,7 @@ new_message(int type, const char *msgfmt, ...) >      va_start(args, msgfmt); >   >      /* first, format the message */ > -    vsnprintf(next_msg, sizeof(next_msg), msgfmt, args); > +    vsnprintf(next_msg, strlen(next_msg), msgfmt, args); >   >      va_end(args); >   > This fix is incorrect. The original commit that changed next_msg to a pointer is probably flawed enough to revert and redevelop rather than try a rolling set of bandaid fixes. Whenever setup_buffer() creates a new buffer it will need to store the size it allocated for use in this vsnprintf() call (and maybe other places that write directly into next_msg without calling setup_buffer to reallocate it first, I didn't look). The setup_buffer_bufsiz variable isn't quite right as-is, because it doesn't include the 'addlen' value passed to setup_buffer(). -- Ian