Re: [evolution-patches] fix for bug #41362



pity there's no stack trace in their bug report :-/

this patch wont do what you're after, the memory (from *malloc*()) is
already pointer-aligned.

The problem is the code later on, where you do buf += len, where len can
be any arbitrary length ... naughty!

Line 199 and 319.

This is where you need to take alignment into account.

I'd suggest something possibly like ...

#define ALIGN(x) ((x) + sizeof(void *) - 1) & (~(sizeof(void *)-1)))

(fwiw, e-memory just uses '4' as the alignment, and it works so far)

len = strlen(res->ai_canonname);
len = ALIGN(len);
if (buflen < ....)
...
...

and possibly, a little later on:

addr = buf;
buf += ALIGN(host->h_len);

And similar for the gethostbyaddr function.

And yeah, alignment is almost certainly the problem!


On Fri, 2003-04-18 at 04:43, Jeffrey Stedfast wrote:
> http://bugzilla.ximian.com/show_bug.cgi?id=41362
> 
> I believe the problem is that of memory alignment, but I can't really be
> sure.
> 
> presuming it is memory alignment, I think this patch should fix it.
> 
> Jeff




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]