(usagi-users 04014) mipv6-daemon: tiny diff

Max Laier <[email protected]> Sat, 12 Jan 2008 02:58:17 +0100
Newsgroups gmane.linux.ipv6.usagi.users
Organization FreeBSD
Message-ID <[email protected]>
--nextPart1267991.hnRBUvMcYA
Content-Type: multipart/mixed;
  boundary="Boundary-01=_76BiH81oyI50uDq"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--Boundary-01=_76BiH81oyI50uDq
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,

just came across the attached while reading the MIPv6-daemon code. =20
Without this diff it seems that memset will stomp over the freshly=20
initialized tmp->lock.  Looks like this slipped through as the lock calls=20
are not checked for error returns.

=2D-=20
/"\  Best regards,                      | [email protected]
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News

--Boundary-01=_76BiH81oyI50uDq
Content-Type: text/x-diff;
  charset="us-ascii";
  name="init_vs_memset.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="init_vs_memset.diff"

diff --git a/src/bcache.c b/src/bcache.c
index f4e40c6..e80438b 100644
=2D-- a/src/bcache.c
+++ b/src/bcache.c
@@ -138,11 +138,11 @@ struct bcentry *bcache_alloc(int type)
 	if (tmp =3D=3D NULL)
 		return NULL;
=20
+	memset(tmp, 0, sizeof(*tmp));
 	if (pthread_rwlock_init(&tmp->lock, NULL)) {
 		free(tmp);
 		return NULL;
 	}
=2D	memset(tmp, 0, sizeof(*tmp));
 	INIT_LIST_HEAD(&tmp->tqe.list);
 	return tmp;
 }

--Boundary-01=_76BiH81oyI50uDq--

--nextPart1267991.hnRBUvMcYA
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQBHiB7AXyyEoT62BG0RAgFNAJ9daLca0D1pV6uwYYH6BSqd+zL7ggCeNxBN
rP/U7L6Etud46pg6E8jUXoo=
=Mp8U
-----END PGP SIGNATURE-----

--nextPart1267991.hnRBUvMcYA--