From owner-freebsd-hackers@FreeBSD.ORG Mon May 21 21:11:22 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66C50106566C for ; Mon, 21 May 2012 21:11:22 +0000 (UTC) (envelope-from ghelmer@palisadesys.com) Received: from ps-1-b.compliancesafe.com (ps-1-b.compliancesafe.com [216.81.161.162]) by mx1.freebsd.org (Postfix) with ESMTP id 2A5818FC0C for ; Mon, 21 May 2012 21:11:22 +0000 (UTC) Received: from mail.palisadesystems.com (localhost [127.0.0.1]) by ps-1-b.compliancesafe.com (8.14.4/8.14.3) with ESMTP id q4LLJ9p6054860; Mon, 21 May 2012 16:19:09 -0500 (CDT) (envelope-from ghelmer@palisadesys.com) Received: from guysmbp.dyn.palisadesys.com (GuysMBP.dyn.palisadesys.com [172.16.2.90]) (authenticated bits=0) by mail.palisadesystems.com (8.14.3/8.14.3) with ESMTP id q4LLApH2017526 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 21 May 2012 16:10:52 -0500 (CDT) (envelope-from ghelmer@palisadesys.com) X-DKIM: Sendmail DKIM Filter v2.8.3 mail.palisadesystems.com q4LLApH2017526 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=palisadesys.com; s=mail; t=1337634652; bh=R1LcdHe7Xj0xIEPRYEJQ6xkxqbVc3WW042MTcvFb5cg=; l=128; h=Subject:Mime-Version:Content-Type:From:In-Reply-To:Date:Cc: Content-Transfer-Encoding:Message-Id:References:To; b=m8g41U/4QTA1FfFIGQsr5fFuJvlgviwXS3T6XLFakiipbc7MnHO/KEwTBdMLdkwQL c/PX/YYc9phOkJ6OOotWxmTcKX8GtVswY+5Tv2gVFVyXTDy03s03O9j7uTklPmtZ1A JgG53MRh3dUVPa33aGnP4UxbXdmxYVifzT7LvTrY= Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=iso-8859-1 From: Guy Helmer In-Reply-To: <4FBA978F.2030908@delphij.net> Date: Mon, 21 May 2012 16:10:51 -0500 Content-Transfer-Encoding: 7bit Message-Id: <0C6268C5-3E3C-40F2-A8C6-23615D05893D@palisadesys.com> References: <4EE466CC-5F93-485C-8E1F-907F8049FD61@palisadesys.com> <4FB6D698.9030305@delphij.net> <4FBA978F.2030908@delphij.net> To: d@delphij.net X-Mailer: Apple Mail (2.1278) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.5 (mail.palisadesystems.com [172.16.1.5]); Mon, 21 May 2012 16:10:52 -0500 (CDT) X-Palisade-MailScanner-Information: Please contact the ISP for more information X-Palisade-MailScanner-ID: q4LLApH2017526 X-Palisade-MailScanner: Found to be clean X-Palisade-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=0.284, required 5, ALL_TRUSTED -1.00, BAYES_00 -1.90, J_CHICKENPOX_54 0.60, J_CHICKENPOX_63 0.60, RP_8BIT 1.98) X-Palisade-MailScanner-From: ghelmer@palisadesys.com X-Spam-Status: No X-PacketSure-Scanned: Yes Cc: freebsd-hackers@freebsd.org Subject: Re: Review of changes for getnetgrent.c X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2012 21:11:22 -0000 On May 21, 2012, at 2:29 PM, Xin Li wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > On 05/21/12 12:02, Guy Helmer wrote: >> >> On May 18, 2012, at 6:09 PM, Xin Li wrote: >> >>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 >>> >>> On 05/18/12 14:58, Guy Helmer wrote: >>>> To close PR bin/83340, I have this change worked up to resolve >>>> memory allocation failure handling and avoid creating bad >>>> entries in the grp list due to memory allocation failures while >>>> building a new entry. >>>> >>>> Before committing, I wanted to run it past others to see if >>>> there were any problems with it. >>> >>> %%% @@ -477,6 +475,13 @@ if (len > 0) { grp->ng_str[strpos] = >>> (char *) malloc(len + 1); + if (grp->ng_str[strpos] == NULL) >>> { + for (freepos = 0; freepos < strpos; freepos++) + >>> if (grp->ng_str[freepos] != NULL) + >>> free(grp->ng_str[freepos]); + free(grp); + >>> return(1); + } bcopy(spos, grp->ng_str[strpos], len + 1); >>> %%% >> >> Like this? >> >> if (len > 0) { grp->ng_str[strpos] = (char *) malloc(len + 1); + >> if (grp->ng_str[strpos] == NULL) { + int freepos; + for >> (freepos = 0; freepos < strpos; freepos++) + >> free(grp->ng_str[freepos]); + free(grp); + return(1); + >> } bcopy(spos, grp->ng_str[strpos], len + 1); } >>> >>> There are a few return without space between the keyword and >>> return value. >> >> Do you recommend I fix all those instances in the file, or just the >> instances in this patch? > > I'd recommend fixing them all (note that you could run into a bigger > commit as the switch() is not style(9) conformant at this time) and we > normally do it in two different commits (one style, and another > functional) when possible. > OK, thank you. Guy -------- This message has been scanned by ComplianceSafe, powered by Palisade's PacketSure.