Skip to content

Commit

Permalink
Fixed EOF error
Browse files Browse the repository at this point in the history
  • Loading branch information
ip2location committed Aug 8, 2022
1 parent 8658370 commit 85a0a11
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ip2location.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ var usagetype_position = [26]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
var addresstype_position = [26]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21}
var category_position = [26]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22}

const api_version string = "9.4.0"
const api_version string = "9.4.1"

var max_ipv4_range = big.NewInt(4294967295)
var max_ipv6_range = big.NewInt(0)
Expand Down Expand Up @@ -327,7 +327,7 @@ func (d *DB) readstr(pos uint32) (string, error) {
var retval string
data := make([]byte, readlen)
_, err := d.f.ReadAt(data, pos2)
if err != nil {
if err != nil && err.Error() != "EOF" { // bypass EOF error coz we are reading 256 which may hit EOF
return "", err
}
strlen := data[0]
Expand Down Expand Up @@ -902,7 +902,6 @@ func (d *DB) query(ipaddress string, mode uint32) (IP2Locationrecord, error) {

ipto32 := d.readuint32_row(fullrow, colsize)
ipto = big.NewInt(int64(ipto32))

} else {
ipfrom = d.readuint128_row(fullrow, 0)

Expand Down

0 comments on commit 85a0a11

Please sign in to comment.