From owner-svn-src-head@freebsd.org Sat Jul 15 20:53:09 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 60409B7BD1C; Sat, 15 Jul 2017 20:53:09 +0000 (UTC) (envelope-from markj@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 mx1.freebsd.org (Postfix) with ESMTPS id 2F9C58475C; Sat, 15 Jul 2017 20:53:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6FKr8I4055466; Sat, 15 Jul 2017 20:53:08 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6FKr8CJ055464; Sat, 15 Jul 2017 20:53:08 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201707152053.v6FKr8CJ055464@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sat, 15 Jul 2017 20:53:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321035 - in head: sbin/savecore sys/kern X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head: sbin/savecore sys/kern X-SVN-Commit-Revision: 321035 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.23 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: Sat, 15 Jul 2017 20:53:09 -0000 Author: markj Date: Sat Jul 15 20:53:08 2017 New Revision: 321035 URL: https://svnweb.freebsd.org/changeset/base/321035 Log: Revert r320918 and have mkdumpheader() handle version string truncation. Reported by: jhb MFC after: 1 week Modified: head/sbin/savecore/savecore.c head/sys/kern/kern_shutdown.c Modified: head/sbin/savecore/savecore.c ============================================================================== --- head/sbin/savecore/savecore.c Sat Jul 15 19:54:03 2017 (r321034) +++ head/sbin/savecore/savecore.c Sat Jul 15 20:53:08 2017 (r321035) @@ -119,7 +119,7 @@ printheader(xo_handle_t *xo, const struct kerneldumphe xo_emit_h(xo, "{P: }{Lwc:Dumptime}{:dumptime/%s}", ctime(&t)); xo_emit_h(xo, "{P: }{Lwc:Hostname}{:hostname/%s}\n", h->hostname); xo_emit_h(xo, "{P: }{Lwc:Magic}{:magic/%s}\n", h->magic); - xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}\n", h->versionstring); + xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}", h->versionstring); xo_emit_h(xo, "{P: }{Lwc:Panic String}{:panic_string/%s}\n", h->panicstring); xo_emit_h(xo, "{P: }{Lwc:Dump Parity}{:dump_parity/%u}\n", h->parity); xo_emit_h(xo, "{P: }{Lwc:Bounds}{:bounds/%d}\n", bounds); Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Sat Jul 15 19:54:03 2017 (r321034) +++ head/sys/kern/kern_shutdown.c Sat Jul 15 20:53:08 2017 (r321035) @@ -1229,6 +1229,7 @@ void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, uint64_t dumplen, uint32_t dumpkeysize, uint32_t blksz) { + size_t dstsize; bzero(kdh, sizeof(*kdh)); strlcpy(kdh->magic, magic, sizeof(kdh->magic)); @@ -1240,7 +1241,9 @@ mkdumpheader(struct kerneldumpheader *kdh, char *magic kdh->dumpkeysize = htod32(dumpkeysize); kdh->blocksize = htod32(blksz); strlcpy(kdh->hostname, prison0.pr_hostname, sizeof(kdh->hostname)); - strlcpy(kdh->versionstring, version, sizeof(kdh->versionstring)); + dstsize = sizeof(kdh->versionstring); + if (strlcpy(kdh->versionstring, version, dstsize) >= dstsize) + kdh->versionstring[dstsize - 2] = '\n'; if (panicstr != NULL) strlcpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); kdh->parity = kerneldump_parity(kdh);