From owner-svn-src-head@FreeBSD.ORG Fri Apr 30 03:13:25 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1A67B106566B; Fri, 30 Apr 2010 03:13:25 +0000 (UTC) (envelope-from alfred@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 0A8F28FC13; Fri, 30 Apr 2010 03:13:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3U3DOTB041214; Fri, 30 Apr 2010 03:13:24 GMT (envelope-from alfred@svn.freebsd.org) Received: (from alfred@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3U3DOpj041212; Fri, 30 Apr 2010 03:13:24 GMT (envelope-from alfred@svn.freebsd.org) Message-Id: <201004300313.o3U3DOpj041212@svn.freebsd.org> From: Alfred Perlstein Date: Fri, 30 Apr 2010 03:13:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207416 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Apr 2010 03:13:25 -0000 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)