svn commit: r285548 - head/sys/kern
Mark Johnston
markj at FreeBSD.org
Tue Jul 14 18:24:06 UTC 2015
Author: markj
Date: Tue Jul 14 18:24:05 2015
New Revision: 285548
URL: https://svnweb.freebsd.org/changeset/base/285548
Log:
Fix some error-handling bugs when core dump compression is enabled:
- Ensure that core dump parameters are initialized in the error path.
- Don't call gzio_fini() on a NULL stream.
Reported by: rpaulo
Modified:
head/sys/kern/imgact_elf.c
Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c Tue Jul 14 17:01:55 2015 (r285547)
+++ head/sys/kern/imgact_elf.c Tue Jul 14 18:24:05 2015 (r285548)
@@ -1241,6 +1241,7 @@ __elfN(coredump)(struct thread *td, stru
compress = (flags & IMGACT_CORE_COMPRESS) != 0;
hdr = NULL;
+ tmpbuf = NULL;
TAILQ_INIT(¬elst);
/* Size the program segments. */
@@ -1255,6 +1256,14 @@ __elfN(coredump)(struct thread *td, stru
__elfN(prepare_notes)(td, ¬elst, ¬esz);
coresize = round_page(hdrsize + notesz) + seginfo.size;
+ /* Set up core dump parameters. */
+ params.offset = 0;
+ params.active_cred = cred;
+ params.file_cred = NOCRED;
+ params.td = td;
+ params.vp = vp;
+ params.gzs = NULL;
+
#ifdef RACCT
if (racct_enable) {
PROC_LOCK(td->td_proc);
@@ -1271,15 +1280,6 @@ __elfN(coredump)(struct thread *td, stru
goto done;
}
- /* Set up core dump parameters. */
- params.offset = 0;
- params.active_cred = cred;
- params.file_cred = NOCRED;
- params.td = td;
- params.vp = vp;
- params.gzs = NULL;
-
- tmpbuf = NULL;
#ifdef GZIO
/* Create a compression stream if necessary. */
if (compress) {
@@ -1336,7 +1336,8 @@ done:
#ifdef GZIO
if (compress) {
free(tmpbuf, M_TEMP);
- gzio_fini(params.gzs);
+ if (params.gzs != NULL)
+ gzio_fini(params.gzs);
}
#endif
while ((ninfo = TAILQ_FIRST(¬elst)) != NULL) {
More information about the svn-src-head
mailing list