[lldb-dev] unaligned cast in TCPSocket::Connect
Pavel Labath via lldb-dev
lldb-dev at lists.llvm.org
Thu Oct 13 11:02:05 PDT 2016
fine by me. We should probably also stop using inet_ntoa as it is not
thread-safe (I don't know what is the safe alternative off-hand).
pl
On 13 October 2016 at 19:00, Zachary Turner via lldb-dev
<lldb-dev at lists.llvm.org> wrote:
> I believe you are correct. We should create an in_addr on the stack and
> memcpy into it.
>
> On Thu, Oct 13, 2016 at 10:52 AM Ted Woodward via lldb-dev
> <lldb-dev at lists.llvm.org> wrote:
>>
>> TCPSocket::Connect has this line:
>>
>> host_str = ::inet_ntoa (*(struct in_addr
>> *)*host_entry->h_addr_list);
>>
>>
>>
>> host_entry->h_addr_list is a char**, while struct in_addr contains a
>> uint32_t. Casting like this (char * to uint_32t *) could cause a bus error
>> on systems that don’t allow non-aligned loads. I think we need to memcpy the
>> data into a struct in_addr variable.
>>
>>
>>
>> Anyone have any thoughts on this?
>>
>>
>>
>> --
>>
>> Qualcomm Innovation Center, Inc.
>>
>> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
>> Linux Foundation Collaborative Project
>>
>>
>>
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>
More information about the lldb-dev
mailing list