mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-17 15:47:14 +02:00
bin
module
vendor
CPR
ConcurrentQueue
Fmt
JSMN
MaxmindDB
.github
bin
dev-bin
doc
include
projects
src
t
CMakeLists.txt
Makefile.am
bad_databases_t.c
bad_pointers_t.c
basic_lookup_t.c
compile_c++_t.pl
data-pool-t.c
data_entry_list_t.c
data_types_t.c
dump_t.c
external_symbols_t.pl
get_value_pointer_bug_t.c
get_value_t.c
ipv4_start_cache_t.c
ipv6_lookup_in_ipv4_t.c
maxminddb_test_helper.c
maxminddb_test_helper.h
metadata_pointers_t.c
metadata_t.c
mmdblookup_t.pl
no_map_get_value_t.c
read_node_t.c
threads_t.c
version_t.c
.gitignore
.gitmodules
.perltidyrc
.uncrustify.cfg
AUTHORS
CMakeLists.txt
Changes.md
LICENSE
Makefile.am
NOTICE
README.dev.md
README.md
bootstrap
common.mk
configure.ac
POCO
SimpleIni
Squirrel
TinyDir
ZMQ
CMakeLists.txt
.gitignore
.gitmodules
CMakeLists.txt
LICENSE
README.md
54 lines
1.6 KiB
C
54 lines
1.6 KiB
C
#include "maxminddb_test_helper.h"
|
|
|
|
void run_tests(int mode, const char *mode_desc)
|
|
{
|
|
const char *filename = "MaxMind-DB-test-broken-pointers-24.mmdb";
|
|
const char *path = test_database_path(filename);
|
|
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
|
free((void *)path);
|
|
|
|
{
|
|
const char *ip = "1.1.1.16";
|
|
MMDB_lookup_result_s result =
|
|
lookup_string_ok(mmdb, ip, filename, mode_desc);
|
|
|
|
MMDB_entry_data_s entry_data;
|
|
int status = MMDB_get_value(&result.entry, &entry_data, NULL);
|
|
|
|
cmp_ok(
|
|
status, "==", MMDB_INVALID_DATA_ERROR,
|
|
"MMDB_get_value returns MMDB_INVALID_DATA_ERROR for bad pointer in data section");
|
|
|
|
MMDB_entry_data_list_s *entry_data_list;
|
|
status = MMDB_get_entry_data_list(&result.entry, &entry_data_list);
|
|
|
|
cmp_ok(
|
|
status, "==", MMDB_INVALID_DATA_ERROR,
|
|
"MMDB_get_entry_data_list returns MMDB_INVALID_DATA_ERROR for bad pointer in data section");
|
|
|
|
MMDB_free_entry_data_list(entry_data_list);
|
|
}
|
|
|
|
{
|
|
const char *ip = "1.1.1.32";
|
|
|
|
int gai_error, mmdb_error;
|
|
MMDB_lookup_result_s UNUSED(result) =
|
|
MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error);
|
|
|
|
cmp_ok(
|
|
mmdb_error, "==", MMDB_CORRUPT_SEARCH_TREE_ERROR,
|
|
"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);
|
|
free(mmdb);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
plan(NO_PLAN);
|
|
for_all_modes(&run_tests);
|
|
done_testing();
|
|
}
|