From owner-svn-src-all@FreeBSD.ORG Mon Jan 28 15:48:32 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1B7B6D4B; Mon, 28 Jan 2013 15:48:32 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0F1176F1; Mon, 28 Jan 2013 15:48:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0SFmVa2023277; Mon, 28 Jan 2013 15:48:31 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0SFmVra023276; Mon, 28 Jan 2013 15:48:31 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201301281548.r0SFmVra023276@svn.freebsd.org> From: John Baldwin Date: Mon, 28 Jan 2013 15:48:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246035 - head/lib/libproc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jan 2013 15:48:32 -0000 Author: jhb Date: Mon Jan 28 15:48:31 2013 New Revision: 246035 URL: http://svnweb.freebsd.org/changeset/base/246035 Log: - Compute the correct size to reallocate when doubling the size of the array of loaded objects to avoid a buffer overrun. - Use reallocf() to avoid leaking memory if the realloc() fails. PR: kern/175648 Submitted by: yuri@rawbw.com (1) MFC after: 1 week Modified: head/lib/libproc/proc_rtld.c Modified: head/lib/libproc/proc_rtld.c ============================================================================== --- head/lib/libproc/proc_rtld.c Mon Jan 28 12:58:37 2013 (r246034) +++ head/lib/libproc/proc_rtld.c Mon Jan 28 15:48:31 2013 (r246035) @@ -44,7 +44,8 @@ map_iter(const rd_loadobj_t *lop, void * if (phdl->nobjs >= phdl->rdobjsz) { phdl->rdobjsz *= 2; - phdl->rdobjs = realloc(phdl->rdobjs, phdl->rdobjsz); + phdl->rdobjs = reallocf(phdl->rdobjs, sizeof(*phdl->rdobjs) * + phdl->rdobjsz); if (phdl->rdobjs == NULL) return (-1); }