Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 May 2012 14:02:17 -0500
From:      Guy Helmer <ghelmer@palisadesys.com>
To:        d@delphij.net
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Review of changes for getnetgrent.c
Message-ID:  <AE6E3D09-1413-4B5E-8A79-1145179F8D62@palisadesys.com>
In-Reply-To: <4FB6D698.9030305@delphij.net>
References:  <4EE466CC-5F93-485C-8E1F-907F8049FD61@palisadesys.com> <4FB6D698.9030305@delphij.net>

next in thread | previous in thread | raw e-mail | index | archive | help

On May 18, 2012, at 6:09 PM, Xin Li wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>=20
> 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.
>>=20
>> Before committing, I wanted to run it past others to see if there
>> were any problems with it.
>=20
> %%%
> @@ -477,6 +475,13 @@
> 					if (len > 0) {
> 						grp->ng_str[strpos] =3D  =
(char *)
> 							malloc(len + 1);
> +						if (grp->ng_str[strpos] =
=3D=3D NULL) {
> +							for (freepos =3D =
0; freepos < strpos; freepos++)
> +								if =
(grp->ng_str[freepos] !=3D 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] =3D  =
(char *)
 							malloc(len + 1);
+						if (grp->ng_str[strpos] =
=3D=3D NULL) {
+							int freepos;
+							for (freepos =3D =
0; freepos < strpos; freepos++)
+								=
free(grp->ng_str[freepos]);
+							free(grp);
+							return(1);
+						}
 						bcopy(spos, =
grp->ng_str[strpos],
 							len + 1);
 					}
>=20
> 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?

Thanks,
Guy

--------
This message has been scanned by ComplianceSafe, powered by Palisade's PacketSure.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AE6E3D09-1413-4B5E-8A79-1145179F8D62>