Menu

#18 GeoIP_next_record corrupt data

open
nobody
None
5
2010-05-25
2010-05-25
Egon Kocjan
No

I've been using this kind of code to do statistics on GeoIP database (like calculating the "centres" of countries based on IPs):

GeoIP *geoip = GeoIP_open("GeoLiteCity.dat", GEOIP_STANDARD);
int iter = GeoIP_init_record_iter(geoip);
GeoIPRecord *r;
while(!GeoIP_next_record(geoip, &r, &iter) && r) {
// use r
GeoIPRecord_delete(r);
}

This code stopped working some time ago (I don't have the first GeoLiteCity.dat, that caused the problem) - GeoIP_next_record is now returning garbage on all GeoLiteCity.dat updates. I have attached a patch file, which seems to fix the problem for me (note: I figured out the binary offset by reading memory dumps, I haven't tested the code on any other .dat files).

Discussion

  • Egon Kocjan

    Egon Kocjan - 2010-05-25

    record_buf offset patch

     
  • BZ

    BZ - 2010-06-23

    Thanks for finding this!

    However, the problem is with the database layout and not the API. Should be fixed with the next GeoLite update. The patch is not needed.

    Have a nice day!

     

Log in to post a comment.