Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Mar 2013 16:19:09 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r247554 - stable/8/lib/libproc
Message-ID:  <201303011619.r21GJ9wn002534@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Mar  1 16:19:09 2013
New Revision: 247554
URL: http://svnweb.freebsd.org/changeset/base/247554

Log:
  MFC 246035:
  - 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

Modified:
  stable/8/lib/libproc/proc_rtld.c
Directory Properties:
  stable/8/lib/libproc/   (props changed)

Modified: stable/8/lib/libproc/proc_rtld.c
==============================================================================
--- stable/8/lib/libproc/proc_rtld.c	Fri Mar  1 16:18:40 2013	(r247553)
+++ stable/8/lib/libproc/proc_rtld.c	Fri Mar  1 16:19:09 2013	(r247554)
@@ -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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303011619.r21GJ9wn002534>