inet_ntoa and segmentation fault

inet_ntoa and segmentation fault

Shachar Shemesh shachar at shemesh.biz
Wed Jul 15 23:46:39 IDT 2009


Oron Peled wrote:
> On 15.07.2009 Shachar Shemesh wrote:
>   
>> The problem:
>> The following code segfaults:
>>     printf("%s\n", inet_ntoa(addr) );
>>
>> The cause: Failing to include the relevant header file.
>>
>> The solution: Add:
>> #include <arpa/inet.h>
>>     
>
> Easier to catch during compile time: CFLAGS='-Wall -Werror'
> This would fail the build because of missing prototypes.
>
>   
You are, of course, right. The thing is, I usually use this function 
(not thread safe etc.) only in tiny test programs, where I don't care as 
much about warnings.

Shachar

-- 
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
http://www.lingnu.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20090715/85275ad7/attachment-0001.html>


More information about the Linux-il mailing list