Re: Crash due to unaligned hostent.h_addr dereference?
Re: Crash due to unaligned hostent.h_addr dereference?
- Subject: Re: Crash due to unaligned hostent.h_addr dereference?
- From: Jeffrey Walton <email@hidden>
- Date: Mon, 16 Sep 2013 16:55:14 -0400
On Mon, Sep 16, 2013 at 12:57 PM, Sean McBride <email@hidden> wrote:
> On Mon, 16 Sep 2013 01:38:03 -0400, Jeffrey Walton said:
>
>>I'm experiencing a crash due to unaligned hostent.h_addr dereference.
>>Its a typedef, so its equivalent to
>>
>> char** ptr = hostent.h_addr;
>>
>>The problem is, ptr = 0x60c00000a7df, so a dereference of ptr leads to a
>>crash.
>>
>>I thought this issue was recently talked about on this list, but I
>>can't find the emails (or was it CFE Dev?). I searched the archives
>>back a couple of months, but I have not been able to locate it.
>>
>>Can anyone recall the title of that topic?
>
> This?
> <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-September/024523.html>
Thanks again Sean. I looked though the thread, but did not see how you
re-aligned the dirent. Could you share?
I ask because I want to make sure my issue with hostent an in_addr is
correct. In my case, Clang/Compiler-RT flagged two accesses (and the
fixes below make the runtime errors disappear):
void DoSomethingWithHosten(const hostent& he)
{
// Assuming he.h_addrtype == AF_INET
char** ip_addr;
const void* ptr = (void*)&he.h_addr;
memcpy(&ip_addr, ptr, sizeof(void*));
...
in_addr ipv4_addr;
memcpy(&ipv4_addr, ip_addr, sizeof(ipv4_addr));
// Now its safe to use ipv4_addr
...
}
Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden