appliedsec/pygeoip

Error under ipython console

vsilent opened this issue · 1 comments

In [158]: gi.country_name_by_addr('64.233.161.99')

/usr/local/lib/python2.7/dist-packages/pygeoip/init.pyc in country_name_by_addr(self, addr)
488 VALID_EDITIONS = (const.COUNTRY_EDITION, const.COUNTRY_EDITION_V6)
489 if self._databaseType in VALID_EDITIONS:
--> 490 return const.COUNTRY_NAMES[self.id_by_addr(addr)]
491 elif self._databaseType in const.CITY_EDITIONS:
492 return self.record_by_addr(addr)['country_name']

/usr/local/lib/python2.7/dist-packages/pygeoip/init.pyc in id_by_addr(self, addr)
427 raise GeoIPError(message)
428
--> 429 return self._seek_country(ipnum) - const.COUNTRY_BEGIN
430
431 def country_code_by_addr(self, addr):

/usr/local/lib/python2.7/dist-packages/pygeoip/init.pyc in _seek_country(self, ipnum)
223 for i in range(2):
224 for j in range(self._recordLength):
--> 225 byte = buf[self._recordLength * i + j]
226 x[i] += ord(byte) << (j * 8)
227 if ipnum & (1 << depth):

IndexError: string index out of range

~ % python --version
Python 2.7.3

~ % gcc --version
gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2

~ % cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.10
DISTRIB_CODENAME=quantal
DISTRIB_DESCRIPTION="Ubuntu 12.10"

This sounds like a broken database, this will get catched in commit ca3743d. If this is not the case, I need the database for more investigation.