Alignment fixups for gethostbyname_r
vapier at gentoo.org
Sun Jan 6 06:19:40 UTC 2008
On Saturday 22 December 2007, Carmelo Amoroso wrote:
> Daniel Jacobowitz wrote:
> > MontaVista noticed that when their kernels were configured to trap
> > on unaligned access gethostbyname_r could mysteriously crash. I
> > tracked this down to an unaligned buffer being passed to
> > gethostbyname_r from some other part of uClibc (afraid I don't
> > remember where from any more). We have to pad the beginning of
> > the buffer to a pointer alignment before we store pointers in
> > it.
> I've merged it into my sh4-nptl branch to do some tests,
> but not possible until Jan 3rd.
> The patch is surely ok, but, the caller of the gethostbyname is the
> real cause of the error, that could happen in some other part,
> being the passed buffer unaligned.
i dont think so. the gethostbyname_r() API takes a char* for its scratch
space which means no alignment requirements are stipulated. internally,
gethostbyname_r() needs to make sure things are aligned properly for however
it uses the scratch space.
the nice thing about alignment tests are they're easy to write ... the bad
thing is that not everyone has native alignment requirements, so it'll pass
fine on the common systems (x86/x86_64), warn on the semi-common (arm/hppa)
(and no one will notice), and only fail on the uncommon (Blackfin).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20080106/d2615860/attachment-0002.pgp
More information about the uClibc