[tpop3d-discuss]alternative implementation of alloc_struct(S, p)

Maurice van der Pot griffon26 at gentoo.org
Mon, 13 Feb 2006 21:06:02 +0100


--g7w8+K/95kPelPD2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hey guys,

I've been running into a problem with the gcc stack protector code that
surfaced because of the use of a locally declared variable in alloc_struct
(util.h:51).

It turns out that if alloc_struct is rewritten to look like this:

  #define alloc_struct(S, p)  do { p =3D xmalloc(sizeof *p); memset(p, 0, s=
izeof(*p)); } while (0)

then the problem disappears.

The bug in the stack protector will be taken care of, but since the alterna=
tive
code is also faster and uses less stack space than the original version of =
alloc_struct,=20
you may want to consider it for inclusion in tpop3d.

For details, please read the following bug report and comment #10 and
#11 in particular:

  https://bugs.gentoo.org/show_bug.cgi?id=3D115285

Best regards,
Maurice.

P.S.: You can also drop the S parameter that way.

--=20
Maurice van der Pot

Gentoo Linux Developer   griffon26@gentoo.org     http://www.gentoo.org
Creator of BiteMe!       griffon26@kfk4ever.com   http://www.kfk4ever.com


--g7w8+K/95kPelPD2
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD8OapMGnpIbeahxwRAlyWAJkB3N8I4fPOe43NxelWCL53WP3QRgCfcqZO
c55kdxVD/nuqW23OwwOV4lQ=
=+Ruq
-----END PGP SIGNATURE-----

--g7w8+K/95kPelPD2--