Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jul 2017 20:53:08 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
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
Message-ID:  <201707152053.v6FKr8CJ055464@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707152053.v6FKr8CJ055464>