kohsuke/geoip — pull request #2 by stefansperber (2013-02-19 12:33:08+00:00)
Title: LookupService#getLocation throws ArrayIndexOutOfBoundsException

Hi Kohsuke,

We're using geoip at Last.fm for looking up user locations. Recently, we noticed some unhandled ArrayIndexOutOfBoundsException occuring:

```
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 254
at com.maxmind.geoip.LookupService.getLocation(LookupService.java:905)
at com.maxmind.geoip.LookupService.getLocation(LookupService.java:627)
at com.maxmind.geoip.LookupService.getLocation(LookupService.java:641)
...
```

Example IPs are 62.56.243.11, 216.13.200.211, 92.39.126.208. The geoiplookup tool returned the following output for these IPs:

```
$ geoiplookup 62.56.243.11
GeoIP City Edition, Rev 1: ���, N/A, N/A, N/A, 4.850000, 31.600000, 0, 0
GeoIP City Edition, Rev 0: ���, N/A, N/A, N/A, 4.850000, 31.600000
```

I traced the exception in the LookupService code and wrote a bugfix which sets 'countryCode' and 'countryName' in Location to 'null' when no lookup is possible.

Let me know what you think,
Stefan