From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2P5q-0006jV-C1 for qemu-devel@nongnu.org; Fri, 17 Aug 2012 12:08:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T2P5p-0007tc-21 for qemu-devel@nongnu.org; Fri, 17 Aug 2012 12:08:14 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42619 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2P5o-0007tY-OZ for qemu-devel@nongnu.org; Fri, 17 Aug 2012 12:08:12 -0400 Message-ID: <502E6C69.4090802@suse.de> Date: Fri, 17 Aug 2012 18:08:09 +0200 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1337680210-20569-1-git-send-email-jim@meyering.net> <1337680210-20569-3-git-send-email-jim@meyering.net> <87d32p63ql.fsf@rho.meyering.net> <502E5EEB.7030500@suse.de> <874no14jo5.fsf@rho.meyering.net> In-Reply-To: <874no14jo5.fsf@rho.meyering.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCHv2 2/2] envlist.c: handle strdup failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jim Meyering Cc: qemu-devel@nongnu.org Am 17.08.2012 17:34, schrieb Jim Meyering: > Andreas F=E4rber wrote: >=20 >> Am 17.08.2012 15:35, schrieb Jim Meyering: >>> Jim Meyering wrote: >>>> From: Jim Meyering >>>> >>>> Without this, envlist_to_environ may silently fail to copy all >>>> strings into the destination buffer, and both callers would leak >>>> any env strings allocated after a failing strdup, because the >>>> freeing code stops at the first NULL pointer. >>>> >>>> Signed-off-by: Jim Meyering >>>> --- >>>> envlist.c | 12 ++++++++++-- >>>> 1 file changed, 10 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/envlist.c b/envlist.c >>>> index be0addb..7532091 100644 >>>> --- a/envlist.c >>>> +++ b/envlist.c >>>> @@ -234,8 +234,16 @@ envlist_to_environ(const envlist_t *envlist, si= ze_t *count) >>>> return (NULL); >>>> >>>> for (entry =3D envlist->el_entries.lh_first; entry !=3D NUL= L; >>>> - entry =3D entry->ev_link.le_next) { >>>> - *(penv++) =3D strdup(entry->ev_var); >>>> + entry =3D entry->ev_link.le_next, penv++) { >>>> + *penv =3D strdup(entry->ev_var); >>>> + if (*penv =3D=3D NULL) { >>>> + char **e =3D env; >>>> + while (e <=3D penv) { >>>> + free(*e++); >>>> + } >>>> + free(env); >>>> + return NULL; >>>> + } >>>> } >>>> *penv =3D NULL; /* NULL terminate the list */ >>> >>> It seems this has been lost in this list's high volume of patches. >>> Anyone interested? Repost desired? >> >> You announced a v3 but replied to v2? >=20 > Here are links to v3: >=20 > [PATCHv3 1/2] envlist.c: convert each TAB(width-4) to equivalent spac= es > https://lists.gnu.org/archive/html/qemu-devel/2012-05/msg02967.html >=20 > [Qemu-devel] [PATCHv3 2/2] envlist.c: handle strdup failure > https://lists.gnu.org/archive/html/qemu-devel/2012-05/msg02966.html I commented on v3. For practical reasons please ping the latest patches and prefer Patchwork links so that no gets committed by accident. Thanks for your efforts in reviewing and fixing all these issues! Andreas >=20 >> Indentation looks odd in 2/2, too. >=20 > That was fixed in v3. >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg