1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Don't leak core_buf or gzfile if doing a compressed core file and we

hit an error condition.

Obtained from: Juniper Networks
This commit is contained in:
Alfred Perlstein 2010-04-30 03:13:24 +00:00
parent feb112c552
commit fba6b1af2e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=207416

View File

@ -1088,8 +1088,10 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
hdrsize = 0;
__elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count);
if (hdrsize + seginfo.size >= limit)
return (EFAULT);
if (hdrsize + seginfo.size >= limit) {
error = EFAULT;
goto done;
}
/*
* Allocate memory for building the header, fill it up,
@ -1097,7 +1099,8 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
*/
hdr = malloc(hdrsize, M_TEMP, M_WAITOK);
if (hdr == NULL) {
return (EINVAL);
error = EINVAL;
goto done;
}
error = __elfN(corehdr)(td, vp, cred, seginfo.count, hdr, hdrsize,
gzfile);
@ -1125,8 +1128,8 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
curproc->p_comm, error);
}
#ifdef COMPRESS_USER_CORES
done:
#ifdef COMPRESS_USER_CORES
if (core_buf)
free(core_buf, M_TEMP);
if (gzfile)