Date: Fri, 30 Apr 2010 03:13:24 +0000 (UTC) From: Alfred Perlstein <alfred@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r207416 - head/sys/kern Message-ID: <201004300313.o3U3DOpj041212@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004300313.o3U3DOpj041212>