blblack/gdnsd — pull request #24 by paravoid (2013-01-13 15:32:48+00:00)
Title: Segfault while reading GeoIPv6.dat

I'm trying gdnsd 1.7.5 with a geoip configuration.

As soon as I switch geoip_db => /usr/share/GeoIP/GeoIP.dat to geoip_db => /usr/share/GeoIP/GeoIPv6.dat, I get a segfault:

```
# gdnsd checkconf
Loading configuration
[...]
plugin_geoip: map 'my_prod_map': Processing GeoIP database '/usr/share/GeoIP/GeoIPv6.dat'
Segmentation fault
```

If I try with geoip_db => /usr/share/GeoIP/GeoIPv6.dat, geoip_db_v4_overlay => /usr/share/GeoIP/GeoIP.dat I get instead:
```
plugin_geoip: map 'my_prod_map': Processing GeoIP database '/usr/share/GeoIP/GeoIPv6.dat'
plugin_geoip: map 'my_prod_map': Primary GeoIP DB '/usr/share/GeoIP/GeoIPv6.dat' is not an IPv6 database and this map uses geoip_v4_overlay
plugin_geoip: map 'my_prod_map': (Re-)loading geoip database '/usr/share/GeoIP/GeoIPv6.dat' failed!
plugin_geoip: map 'my_prod_map': cannot continue initial load
```

Unfortunately gdb doesn't help much here, not sure why:
```
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x0000000000000000 in ?? ()
```

I built a developer build which instead prints:
17:44:14 gdnsd [26639] fatal: Assertion 'depth > 0' failed in list_xlate_recurse() at gdgeoip.c:413

Running under gdb that and breaking on list_xlate_recurse() reveals a call with depth=32, then a call with depth=31, then depth=30 and so on, until one with deph=0, where it finally aborts.

The files came from Debian's
http://packages.debian.org/sid/all/geoip-database/download
which in turn are MaxMind's 2013-01-08 databases.