"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/bad_pointers_t.c" between
libmaxminddb-1.5.0.tar.gz and libmaxminddb-1.5.2.tar.gz

About: libmaxminddb is a library that provides functions for working with MaxMind DB files (free GeoLite 2 or commercial GeoIP2).

bad_pointers_t.c  (libmaxminddb-1.5.0):bad_pointers_t.c  (libmaxminddb-1.5.2)
#include "maxminddb_test_helper.h" #include "maxminddb_test_helper.h"
void run_tests(int mode, const char *mode_desc) void run_tests(int mode, const char *mode_desc) {
{
const char *filename = "MaxMind-DB-test-broken-pointers-24.mmdb"; const char *filename = "MaxMind-DB-test-broken-pointers-24.mmdb";
const char *path = test_database_path(filename); const char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free((void *)path);
{ {
const char *ip = "1.1.1.16"; const char *ip = "1.1.1.16";
MMDB_lookup_result_s result = MMDB_lookup_result_s result =
lookup_string_ok(mmdb, ip, filename, mode_desc); lookup_string_ok(mmdb, ip, filename, mode_desc);
MMDB_entry_data_s entry_data; MMDB_entry_data_s entry_data;
int status = MMDB_get_value(&result.entry, &entry_data, NULL); int status = MMDB_get_value(&result.entry, &entry_data, NULL);
cmp_ok( cmp_ok(status,
status, "==", MMDB_INVALID_DATA_ERROR, "==",
"MMDB_get_value returns MMDB_INVALID_DATA_ERROR for bad pointer in d MMDB_INVALID_DATA_ERROR,
ata section"); "MMDB_get_value returns MMDB_INVALID_DATA_ERROR for bad pointer "
"in data section");
MMDB_entry_data_list_s *entry_data_list; MMDB_entry_data_list_s *entry_data_list;
status = MMDB_get_entry_data_list(&result.entry, &entry_data_list); status = MMDB_get_entry_data_list(&result.entry, &entry_data_list);
cmp_ok( cmp_ok(status,
status, "==", MMDB_INVALID_DATA_ERROR, "==",
"MMDB_get_entry_data_list returns MMDB_INVALID_DATA_ERROR for bad po MMDB_INVALID_DATA_ERROR,
inter in data section"); "MMDB_get_entry_data_list returns MMDB_INVALID_DATA_ERROR for "
"bad pointer in data section");
MMDB_free_entry_data_list(entry_data_list); MMDB_free_entry_data_list(entry_data_list);
} }
{ {
const char *ip = "1.1.1.32"; const char *ip = "1.1.1.32";
int gai_error, mmdb_error; int gai_error, mmdb_error;
MMDB_lookup_result_s UNUSED(result) = MMDB_lookup_result_s UNUSED(result) =
MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error); MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error);
cmp_ok( cmp_ok(mmdb_error,
mmdb_error, "==", MMDB_CORRUPT_SEARCH_TREE_ERROR, "==",
"MMDB_lookup_string sets mmdb_error to MMDB_CORRUPT_SEARCH_TREE_ERRO MMDB_CORRUPT_SEARCH_TREE_ERROR,
R when a search tree record points outside the data section"); "MMDB_lookup_string sets mmdb_error to "
"MMDB_CORRUPT_SEARCH_TREE_ERROR when a search tree record "
"points outside the data section");
} }
MMDB_close(mmdb); MMDB_close(mmdb);
free(mmdb); free(mmdb);
} }
int main(void) int main(void) {
{
plan(NO_PLAN); plan(NO_PLAN);
for_all_modes(&run_tests); for_all_modes(&run_tests);
done_testing(); done_testing();
} }
 End of changes. 5 change blocks. 
16 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)