mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-18 15:30:21 +00:00
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
This commit is contained in:
parent
80bee71335
commit
02d131ad11
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285548
@ -1241,6 +1241,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
|
||||
|
||||
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, struct vnode *vp, off_t limit, int flags)
|
||||
__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, struct vnode *vp, off_t limit, int flags)
|
||||
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 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
|
||||
#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) {
|
||||
|
Loading…
Reference in New Issue
Block a user