IP2Location C library enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather station code, weather station name, mobile, usage types, etc that any IP address or hostname originates from.
I noticed something weird with the read functions where would be read from shm, even though IP2LOCATION_FILE_IO is configured as the access type when the file pointer is NULL.
Consider this snipper from the IP2Location_read32 function in IP2Loc_DBInterface.c:
if (DB_access_type == IP2LOCATION_FILE_IO && handle != NULL)
{
// reads from file
}
else
{
// reads from shm
}
I think the handle != NULL check should be done one level deeper. However, I'm not sure what the function should return in that case.
The following code would obviously result in a segfault:
auto db = IP2Location_open("data/IP-COUNTRY-SAMPLE.BIN");
db->filehandle = NULL;
auto record = IP2Location_get_all(db, "127.0.0.1");
I noticed something weird with the read functions where would be read from shm, even though
IP2LOCATION_FILE_IO
is configured as the access type when the file pointer isNULL
.Consider this snipper from the
IP2Location_read32
function inIP2Loc_DBInterface.c
:I think the
handle != NULL
check should be done one level deeper. However, I'm not sure what the function should return in that case.The following code would obviously result in a segfault: