linuxstb / pidvbip

tvheadend client for the Raspberry Pi
http://www.pidvbip.org
GNU General Public License v2.0
53 stars 22 forks source link

Resolving hostname fails #9

Closed TonivdW closed 11 years ago

TonivdW commented 11 years ago

In file htsp.c, function get_ip() the buffer passed to inet_ntop() is one byte too short. If you are trying to connect to a host that has an IP-adress with all octets as 3 digits the program fails with a cryptic message: Can't resolve host: No space left on device

The malloc() does account for the 15+1, but the inet_ntop() does not and passes 15 as length for the buffer.

After I changed: if(inet_ntop(AF_INET, (void )hent->h_addr_list[0], ip, iplen) == NULL) into: if(inet_ntop(AF_INET, (void )hent->h_addr_list[0], ip, iplen+1) == NULL) it now works for me.

(I know, I should really learn how to supply proper patches...)

linuxstb commented 11 years ago

Thanks for the report. After reading the inet_ntop manpage, I've cleaned up the function to use INET_ADDRSTRLEN (which is defined to be 16) instead of iplen. This should fix it.