mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Squashed 'src/deps/src/libmaxminddb/' changes from e26013e1d2..7acfe43a72
7acfe43a72 Bumped version to 1.10.0 3fcb19e6e2 Set release date 19bc81a013 Update test submodule 8493aff051 Add change log entry for #346 feb088a7ff Merge pull request #349 from maxmind/greg/fix-4-gb-search-tree-lookups f6a3ccf945 Do not cause integer overflow f33d0224c2 Merge pull request #346 from Zopolis4/moregnuinstalldirs 8b4bf0dec9 Make greater use of GNUInstallDirs c7f2d1dc99 Merge pull request #345 from maxmind/greg/update-json-comments cbd4c945b4 Fix some typos 1e5187230b Clarify that mmdblookup does not produce JSON a7c9f3bb56 Merge pull request #343 from maxmind/greg/changelog-342 573bac55b6 Add changes entry for #342 5c5d875902 Merge pull request #342 from clwluvw/cmake 878e2ca407 cmake: generate install targets optionally f19112465d cmake: make binary build optional baeb0439ce Merge pull request #340 from maxmind/greg/1.9.1 git-subtree-dir: src/deps/src/libmaxminddb git-subtree-split: 7acfe43a72a5043d01cc3dd6429005acdf812cb3
This commit is contained in:
parent
db8fec5254
commit
e66e2bb891
11 changed files with 204 additions and 165 deletions
|
|
@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.9)
|
|||
|
||||
project(maxminddb
|
||||
LANGUAGES C
|
||||
VERSION 1.9.1
|
||||
VERSION 1.10.0
|
||||
)
|
||||
set(MAXMINDDB_SOVERSION 0.0.7)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
|
@ -13,6 +13,8 @@ if (WIN32)
|
|||
endif()
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)
|
||||
option(BUILD_TESTING "Build test programs" ON)
|
||||
option(MAXMINDDB_BUILD_BINARIES "Build binaries" ON)
|
||||
option(MAXMINDDB_INSTALL "Generate the install target" ON)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
|
|
@ -90,17 +92,20 @@ set(MAXMINDB_HEADERS
|
|||
)
|
||||
set_target_properties(maxminddb PROPERTIES PUBLIC_HEADER "${MAXMINDB_HEADERS}")
|
||||
|
||||
install(TARGETS maxminddb
|
||||
EXPORT maxminddb)
|
||||
if (MAXMINDDB_INSTALL)
|
||||
install(TARGETS maxminddb
|
||||
EXPORT maxminddb)
|
||||
|
||||
# This is required to work with FetchContent
|
||||
install(EXPORT maxminddb
|
||||
FILE maxminddb-config.cmake
|
||||
NAMESPACE maxminddb::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/maxminddb)
|
||||
# This is required to work with FetchContent
|
||||
install(EXPORT maxminddb
|
||||
FILE maxminddb-config.cmake
|
||||
NAMESPACE maxminddb::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/maxminddb)
|
||||
endif()
|
||||
|
||||
# We always want to build mmdblookup
|
||||
add_subdirectory(bin)
|
||||
if (MAXMINDDB_BUILD_BINARIES)
|
||||
add_subdirectory(bin)
|
||||
endif()
|
||||
|
||||
if (BUILD_TESTING)
|
||||
enable_testing()
|
||||
|
|
@ -110,14 +115,16 @@ endif()
|
|||
# Generate libmaxminddb.pc file for pkg-config
|
||||
# Set the required variables as same with autotools
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix \${prefix})
|
||||
set(libdir \${exec_prefix}/lib)
|
||||
set(includedir \${prefix}/include)
|
||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(libdir ${CMAKE_INSTALL_LIBDIR})
|
||||
set(includedir ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
set(PACKAGE_VERSION ${maxminddb_VERSION})
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libmaxminddb.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
|
||||
@ONLY)
|
||||
if (MAXMINDDB_INSTALL)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libmaxminddb.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
|
||||
@ONLY)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
endif()
|
||||
|
|
|
|||
14
Changes.md
14
Changes.md
|
|
@ -1,3 +1,15 @@
|
|||
## 1.10.0 - 2024-06-10
|
||||
|
||||
* When building with CMake, it is now possible to disable the building
|
||||
of binaries (e.g., `mmdblookup`) with the `MAXMINDDB_BUILD_BINARIES`
|
||||
option and the install target generation with the `MAXMINDDB_INSTALL`
|
||||
option. Pull request by Seena Fallah. GitHub #342.
|
||||
* CMake now makes greater use of GNUInstallDirs. Pull request by Maximilian
|
||||
Downey Twiss. GitHub #346.
|
||||
* The reader can now lookup records on a database with a search tree
|
||||
that is greater than 4 gigabytes without sometimes returning erroneous
|
||||
results due to an integer overflow.
|
||||
|
||||
## 1.9.1 - 2024-01-09
|
||||
|
||||
* `SSIZE_MAX` is now defined conditionally on Windows. The 1.9.0
|
||||
|
|
@ -230,7 +242,7 @@
|
|||
code to think it had found valid metadata when none existed. In addition,
|
||||
this could lead to an attempt to read past the end of the database
|
||||
entirely. Finally, if there are multiple metadata markers in the database,
|
||||
we treat the final one as the start of the metdata, instead of the first.
|
||||
we treat the final one as the start of the metadata, instead of the first.
|
||||
Implemented by Tobias Stoeckmann. GitHub #102.
|
||||
* Don't attempt to mmap a file that is too large to be mmapped on the
|
||||
system. Implemented by Tobias Stoeckmann. GitHub #101.
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ if(NOT MSVC)
|
|||
|
||||
target_link_libraries(mmdblookup maxminddb pthread)
|
||||
|
||||
install(
|
||||
TARGETS mmdblookup
|
||||
DESTINATION bin
|
||||
)
|
||||
if (MAXMINDDB_INSTALL)
|
||||
install(
|
||||
TARGETS mmdblookup
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.63])
|
||||
AC_INIT([libmaxminddb], [1.9.1], [support@maxmind.com])
|
||||
AC_INIT([libmaxminddb], [1.10.0], [support@maxmind.com])
|
||||
AC_CONFIG_SRCDIR([include/maxminddb.h])
|
||||
AC_CONFIG_HEADERS([config.h include/maxminddb_config.h])
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ mmdblookup --file [FILE PATH] --ip [IP ADDRESS] [DATA PATH]
|
|||
# DESCRIPTION
|
||||
|
||||
`mmdblookup` looks up an IP address in the specified MaxMind DB file. The
|
||||
record for the IP address is displayed in a JSON-like structure with type
|
||||
annotations.
|
||||
record for the IP address is displayed with `{}` to denote maps and `[]` to
|
||||
denote arrays. The values are followed by type annotations. This output is
|
||||
_not_ JSON and is not intended to be used as such. If you need JSON, please
|
||||
see [`mmdbinspect`](https://github.com/maxmind/mmdbinspect).
|
||||
|
||||
If an IP's data entry resolves to a map or array, you can provide a lookup
|
||||
path to only show part of that data.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define MAXMINDDB_CONFIG_H
|
||||
|
||||
#ifndef MMDB_UINT128_USING_MODE
|
||||
/* Define as 1 if we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */
|
||||
/* Define as 1 if we use unsigned int __attribute__ ((__mode__(TI))) for uint128 values */
|
||||
#cmakedefine MMDB_UINT128_USING_MODE @MMDB_UINT128_USING_MODE@
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define MAXMINDDB_CONFIG_H
|
||||
|
||||
#ifndef MMDB_UINT128_USING_MODE
|
||||
/* Define as 1 if we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */
|
||||
/* Define as 1 if we use unsigned int __attribute__ ((__mode__(TI))) for uint128 values */
|
||||
#define MMDB_UINT128_USING_MODE 0
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -947,7 +947,7 @@ static int find_address_in_search_tree(const MMDB_s *const mmdb,
|
|||
return MMDB_UNKNOWN_DATABASE_FORMAT_ERROR;
|
||||
}
|
||||
|
||||
uint32_t value = 0;
|
||||
uint64_t value = 0;
|
||||
uint16_t current_bit = 0;
|
||||
if (mmdb->metadata.ip_version == 6 && address_family == AF_INET) {
|
||||
value = mmdb->ipv4_start_node.node_value;
|
||||
|
|
@ -961,6 +961,7 @@ static int find_address_in_search_tree(const MMDB_s *const mmdb,
|
|||
uint8_t bit =
|
||||
1U & (address[current_bit >> 3] >> (7 - (current_bit % 8)));
|
||||
|
||||
// Note that value*record_info.record_length can be larger than 2**32
|
||||
record_pointer = &search_tree[value * record_info.record_length];
|
||||
if (record_pointer + record_info.record_length > mmdb->data_section) {
|
||||
return MMDB_CORRUPT_SEARCH_TREE_ERROR;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 31a33b3c09ac53028216e82f3d8a6d33749a8df5
|
||||
Subproject commit 880f6b4b5eb6c12ea9d5c70dd201dec2cb5639a2
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
void test_metadata(MMDB_s *mmdb, const char *mode_desc) {
|
||||
cmp_ok(mmdb->metadata.node_count,
|
||||
"==",
|
||||
37,
|
||||
"node_count is 37 - %s",
|
||||
163,
|
||||
"node_count is 163 - %s",
|
||||
mode_desc);
|
||||
cmp_ok(mmdb->metadata.record_size,
|
||||
"==",
|
||||
|
|
@ -197,7 +197,7 @@ void test_metadata_as_data_entry_list(MMDB_s *mmdb, const char *mode_desc) {
|
|||
if (strcmp(key_name, "node_count") == 0) {
|
||||
MMDB_entry_data_list_s *value = entry_data_list =
|
||||
entry_data_list->next;
|
||||
cmp_ok(value->entry_data.uint32, "==", 37, "node_count == 37");
|
||||
cmp_ok(value->entry_data.uint32, "==", 163, "node_count == 163");
|
||||
} else if (strcmp(key_name, "record_size") == 0) {
|
||||
MMDB_entry_data_list_s *value = entry_data_list =
|
||||
entry_data_list->next;
|
||||
|
|
|
|||
279
t/read_node_t.c
279
t/read_node_t.c
|
|
@ -74,50 +74,55 @@ void run_24_bit_record_tests(int mode, const char *mode_desc) {
|
|||
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
||||
free(path);
|
||||
|
||||
const uint32_t tests[7][5] = {
|
||||
{0, 1, MMDB_RECORD_TYPE_SEARCH_NODE, 242, MMDB_RECORD_TYPE_EMPTY},
|
||||
{
|
||||
80,
|
||||
81,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
197,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
96,
|
||||
97,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
103,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
104,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
127,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
315,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
},
|
||||
{
|
||||
132,
|
||||
329,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
241,
|
||||
96,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
}};
|
||||
const uint32_t tests[7][5] = {{
|
||||
0,
|
||||
1,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
435,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
80,
|
||||
81,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
323,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
96,
|
||||
97,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
148,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
103,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
104,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
127,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
514,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
},
|
||||
{
|
||||
132,
|
||||
527,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
241,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
}};
|
||||
run_read_node_tests(mmdb, tests, 7, 24);
|
||||
|
||||
MMDB_close(mmdb);
|
||||
|
|
@ -130,50 +135,55 @@ void run_28_bit_record_tests(int mode, const char *mode_desc) {
|
|||
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
||||
free(path);
|
||||
|
||||
const uint32_t tests[7][5] = {
|
||||
{0, 1, MMDB_RECORD_TYPE_SEARCH_NODE, 242, MMDB_RECORD_TYPE_EMPTY},
|
||||
{
|
||||
80,
|
||||
81,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
197,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
96,
|
||||
97,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
103,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
104,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
127,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
315,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
},
|
||||
{
|
||||
132,
|
||||
329,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
241,
|
||||
96,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
}};
|
||||
const uint32_t tests[7][5] = {{
|
||||
0,
|
||||
1,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
435,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
80,
|
||||
81,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
323,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
96,
|
||||
97,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
148,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
103,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
104,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
127,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
514,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
},
|
||||
{
|
||||
132,
|
||||
527,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
241,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
}};
|
||||
run_read_node_tests(mmdb, tests, 7, 28);
|
||||
|
||||
MMDB_close(mmdb);
|
||||
|
|
@ -186,50 +196,55 @@ void run_32_bit_record_tests(int mode, const char *mode_desc) {
|
|||
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
||||
free(path);
|
||||
|
||||
const uint32_t tests[7][5] = {
|
||||
{0, 1, MMDB_RECORD_TYPE_SEARCH_NODE, 242, MMDB_RECORD_TYPE_EMPTY},
|
||||
{
|
||||
80,
|
||||
81,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
197,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
96,
|
||||
97,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
103,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
104,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
127,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
315,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
},
|
||||
{
|
||||
132,
|
||||
329,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
241,
|
||||
96,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
}};
|
||||
const uint32_t tests[7][5] = {{
|
||||
0,
|
||||
1,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
435,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
80,
|
||||
81,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
323,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
96,
|
||||
97,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
148,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
103,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
104,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
},
|
||||
{
|
||||
127,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
514,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
},
|
||||
{
|
||||
132,
|
||||
527,
|
||||
MMDB_RECORD_TYPE_DATA,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
},
|
||||
{
|
||||
241,
|
||||
444,
|
||||
MMDB_RECORD_TYPE_EMPTY,
|
||||
242,
|
||||
MMDB_RECORD_TYPE_SEARCH_NODE,
|
||||
}};
|
||||
|
||||
run_read_node_tests(mmdb, tests, 7, 32);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue