Revert r320918 and have mkdumpheader() handle version string truncation.

Reported by:	jhb
MFC after:	1 week
This commit is contained in:
Mark Johnston 2017-07-15 20:53:08 +00:00
parent d32ed2c735
commit ab384d75db
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=321035
2 changed files with 5 additions and 2 deletions

View File

@ -119,7 +119,7 @@ printheader(xo_handle_t *xo, const struct kerneldumpheader *h, const char *devic
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);

View File

@ -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, uint32_t archver,
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);