Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#17 Windows code derefereces the hostent struct incorrectly

open
nobody
None
5
2010-05-03
2010-05-03
Anonymous
No

Non-Windows code works just fine. On Windows builds _GeoIP_lookupaddress returns an incorrect value due to the way phe->h_addr_list is dereferenced.

The line in GeoIP.c

addr = *(phe->h_addr_list[0]);

changed to

*(unsigned long*) (phe->h_addr_list[0])

or more correctly for windows

addr = ((IN_ADDR *) phe->h_addr_list[0])->S_un.S_addr;

produces the desired result.

Discussion

  • Boris Zentner
    Boris Zentner
    2010-06-23

    Thanks,

    I copied the second line to cvs.

    Have a nice day!