I'm using GeoIP 1.4.5, sort of. I'm on Solaris 10, and don't have access to vasprintf, so I copied geoiplookup.c from the CVS tree and modified it to force the use of vnsprintf, which I have. When I run apps/geoiplookup.c in some cases, I get a seg fault. I'm using the GeoLite City binary database. Here's the relevant problem:
(gdb) down
#3 0x0805156d in geoiplookup (gi=0x80655f0,
hostname=0x8047d81 "48.56.45.210", i=2) at geoiplookup.c:177
(gdb) print gir
$4 = (GeoIPRecord *) 0x8067a88
(gdb) print *gir
$5 = {country_code = 0x80620e3 "US", country_code3 = 0xfef89804 "USA",
country_name = 0xfef8a2c1 "United States", region = 0x0, city = 0x0,
postal_code = 0x0, latitude = 38, longitude = -97, {metro_code = 0,
dma_code = 0}, area_code = 0, charset = 0,
continent_code = 0xfef8a6e3 "NA"}
If you look at the CSV versions, this address corresponds to block 223, which contains no information for region, city or postal code. The empty strings in the DB seem to be converted to 0x0 in the C struct, which causes the printf to seg fault because it doesn't check for null.
Hi Samuel,
Thanks for your bug report!
This bug is fixed in the upcoming 1.4.6 release.
( as well as all other known solaris problems. )
Have a nice day