ipipdotnet / ipdb-go

IPIP.net officially supported IP database ipdb format parsing library
Apache License 2.0
299 stars 49 forks source link

Fix Process crash when parsing the wrong DB file #2

Closed fcharlie closed 5 years ago

fcharlie commented 5 years ago

When we parse the DB file, the wrong DB file metaLength may be larger than the file size, and illegal address access may occur when calling 'json.Unmarshal' and be killed by the system.

ipipdotnet commented 5 years ago

@fcharlie The problem of file size and metadata inconsistency is to let users know

fcharlie commented 5 years ago

@ipipdotnet I think your point of view is correct, but we should return the error instead of letting the process crash directly. Usually, a server process crashes, and the cause of the error is hard to find.

ilsanbao commented 5 years ago

@fcharlie When the data file is incomplete, it will cause the program to crash, but this is not caused by "json.Unmarshal". Let's fix this problem.