GeoIP_database_info is not returning full string from database #85
Comments
For "ipv6calc" compatibility tests I have here all older versions and it looks like that current binary dat files are incompatible at least since version 1.4.4:
Imho one has to check/track changes in the dat file generator by code review and/or testing older releases of the dat file to see when this bug was introduced. |
It looks to me that the current code finds the start of the database info string successfully, but is prone to truncating the string. Without knowing what the legacy database format looks like, it's hard to debug this in my head but it seems a bit strange that the loop variable i is involved both in finding the start of the string and its length. Would it not work to keep the code that finds the start of the database info and then take everything from there to a NULL character as long as it doesn't overflow the malloc-ed buffer? |
That might work. I am not sure why the code was designed that way. This is further complicated by the fact that there are several different variations of the legacy format, all without detailed specifications. |
I've just been looking at this and I think the current code is correct. The problem is the databases, not the code. The database info structure is at the end of the file, and by dumping the file contents using od, it's clear that the current GeoLite legacy databases have truncated database info strings, matching the output from @pbiering's test program. So it's the database generator that needs looking at. |
@pghmcfc, thanks for looking into it! We'll take a look at the generation code. |
This should be fixed in the latest GeoLite legacy databases. |
I am going to close this issue as both the database reader and generation should now be fixed. Thanks for reporting! |
The new databases look good to me. Thanks! |
See also: https://bugzilla.redhat.com/show_bug.cgi?id=1426853
Looks like #79 is not really fixed and also it looks like output depends on database version:
Old DBs from 2013 using library 1.6.9 (OK)
Old DBs using library version 1.5.0 (OK)
New DBs from 2016+ using library version 1.6.9 (BUGGY)
New DBs from 2016+ using library version 1.5.0 (BUGGY)
Test code is:
The text was updated successfully, but these errors were encountered: