Approved by: gallatin (mentor)

Sync with i386.
Don't write crashdumps outside partition boundaries.
This commit is contained in:
Bernd Walter 2003-01-03 00:19:54 +00:00
parent 1f88bad30a
commit fcab1602ae
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108576

View File

@ -73,6 +73,18 @@ dumpsys(struct dumperinfo *di)
strncpy(kdh.panicstring, panicstr, sizeof kdh.panicstring);
kdh.parity = kerneldump_parity(&kdh);
/*
* Check if we will have enough room to save the coredump.
* The partition size needed is the sum of:
* Memory to save + header + trailer + Room to leave untouched
* at partition head. (an arbitrary amount).
*/
if (di->mediasize <
Maxmem * (off_t)PAGE_SIZE + sizeof kdh * 2 + 64*1024) {
printf("\nDump failed. Partition too small.\n");
return;
}
dumplo = di->mediaoffset + di->mediasize - Maxmem * (off_t)PAGE_SIZE;
dumplo -= sizeof kdh * 2;
i = di->dumper(di->priv, &kdh, NULL, dumplo, sizeof kdh);