Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 248 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
something about inet_ntoa()

#1
I write a server using the function `char* inet_ntoa(struct in_addr in),` When I included the header
`<sys/socket.h>` and `<netinet/in.h>` ,an executable binary can be generated with compiler warnings, but a segment fault happens, when the program handle the return string from `inet_ntoa`. But when I added the header `<arpa/inet.h>,` everything seems ok.

What's the matter?
Reply

#2
`arpa/inet.h` contains the declaration of `char* inet_ntoa(struct in_addr in)`. If you don't include this header your compiler will use implicit declaration `int inet_ntoa()`. Wrong declaration can easily lead to segfault, especially if you are on system where `sizeof(int)!=sizeof(void*)`.

If you are using `gcc` you can add `-Wall` flag. `gcc` will warn you about using functions without explicit declaration.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through