svn commit: r207416 - head/sys/kern
Alfred Perlstein
alfred at FreeBSD.org
Fri Apr 30 03:13:25 UTC 2010
Author: alfred
Date: Fri Apr 30 03:13:24 2010
New Revision: 207416
URL: http://svn.freebsd.org/changeset/base/207416
Log:
Don't leak core_buf or gzfile if doing a compressed core file and we
hit an error condition.
Obtained from: Juniper Networks
Modified:
head/sys/kern/imgact_elf.c
Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c Fri Apr 30 03:10:53 2010 (r207415)
+++ head/sys/kern/imgact_elf.c Fri Apr 30 03:13:24 2010 (r207416)
@@ -1088,8 +1088,10 @@ __elfN(coredump)(struct thread *td, stru
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, stru
*/
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, stru
curproc->p_comm, error);
}
-#ifdef COMPRESS_USER_CORES
done:
+#ifdef COMPRESS_USER_CORES
if (core_buf)
free(core_buf, M_TEMP);
if (gzfile)
More information about the svn-src-all
mailing list