Skip to content

Commit f19981a

Browse files
committed
Merge tag '1.10.0' into ubuntu-ppa
2 parents 92b661e + 7acfe43 commit f19981a

File tree

11 files changed

+212
-165
lines changed

11 files changed

+212
-165
lines changed

CMakeLists.txt

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.9)
22

33
project(maxminddb
44
LANGUAGES C
5-
VERSION 1.9.0
5+
VERSION 1.10.0
66
)
77
set(MAXMINDDB_SOVERSION 0.0.7)
88
set(CMAKE_C_STANDARD 99)
@@ -13,6 +13,8 @@ if (WIN32)
1313
endif()
1414
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)
1515
option(BUILD_TESTING "Build test programs" ON)
16+
option(MAXMINDDB_BUILD_BINARIES "Build binaries" ON)
17+
option(MAXMINDDB_INSTALL "Generate the install target" ON)
1618

1719
include(GNUInstallDirs)
1820

@@ -90,17 +92,20 @@ set(MAXMINDB_HEADERS
9092
)
9193
set_target_properties(maxminddb PROPERTIES PUBLIC_HEADER "${MAXMINDB_HEADERS}")
9294

93-
install(TARGETS maxminddb
94-
EXPORT maxminddb)
95+
if (MAXMINDDB_INSTALL)
96+
install(TARGETS maxminddb
97+
EXPORT maxminddb)
9598

96-
# This is required to work with FetchContent
97-
install(EXPORT maxminddb
98-
FILE maxminddb-config.cmake
99-
NAMESPACE maxminddb::
100-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/maxminddb)
99+
# This is required to work with FetchContent
100+
install(EXPORT maxminddb
101+
FILE maxminddb-config.cmake
102+
NAMESPACE maxminddb::
103+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/maxminddb)
104+
endif()
101105

102-
# We always want to build mmdblookup
103-
add_subdirectory(bin)
106+
if (MAXMINDDB_BUILD_BINARIES)
107+
add_subdirectory(bin)
108+
endif()
104109

105110
if (BUILD_TESTING)
106111
enable_testing()
@@ -110,14 +115,16 @@ endif()
110115
# Generate libmaxminddb.pc file for pkg-config
111116
# Set the required variables as same with autotools
112117
set(prefix ${CMAKE_INSTALL_PREFIX})
113-
set(exec_prefix \${prefix})
114-
set(libdir \${exec_prefix}/lib)
115-
set(includedir \${prefix}/include)
118+
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
119+
set(libdir ${CMAKE_INSTALL_LIBDIR})
120+
set(includedir ${CMAKE_INSTALL_INCLUDEDIR})
116121
set(PACKAGE_VERSION ${maxminddb_VERSION})
117122

118-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libmaxminddb.pc.in
119-
${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
120-
@ONLY)
123+
if (MAXMINDDB_INSTALL)
124+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libmaxminddb.pc.in
125+
${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
126+
@ONLY)
121127

122-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
123-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
128+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
129+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
130+
endif()

Changes.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## 1.10.0 - 2024-06-10
2+
3+
* When building with CMake, it is now possible to disable the building
4+
of binaries (e.g., `mmdblookup`) with the `MAXMINDDB_BUILD_BINARIES`
5+
option and the install target generation with the `MAXMINDDB_INSTALL`
6+
option. Pull request by Seena Fallah. GitHub #342.
7+
* CMake now makes greater use of GNUInstallDirs. Pull request by Maximilian
8+
Downey Twiss. GitHub #346.
9+
* The reader can now lookup records on a database with a search tree
10+
that is greater than 4 gigabytes without sometimes returning erroneous
11+
results due to an integer overflow.
12+
13+
## 1.9.1 - 2024-01-09
14+
15+
* `SSIZE_MAX` is now defined conditionally on Windows. The 1.9.0
16+
release would cause a redefinition warning when compiled with MinGW.
17+
Reported by Andreas Vögele. GitHub #338.
18+
119
## 1.9.0 - 2024-01-09
220

321
* On very large databases, the calculation to determine the search tree
@@ -224,7 +242,7 @@
224242
code to think it had found valid metadata when none existed. In addition,
225243
this could lead to an attempt to read past the end of the database
226244
entirely. Finally, if there are multiple metadata markers in the database,
227-
we treat the final one as the start of the metdata, instead of the first.
245+
we treat the final one as the start of the metadata, instead of the first.
228246
Implemented by Tobias Stoeckmann. GitHub #102.
229247
* Don't attempt to mmap a file that is too large to be mmapped on the
230248
system. Implemented by Tobias Stoeckmann. GitHub #101.

bin/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ if(NOT MSVC)
1515

1616
target_link_libraries(mmdblookup maxminddb pthread)
1717

18-
install(
19-
TARGETS mmdblookup
20-
DESTINATION bin
21-
)
18+
if (MAXMINDDB_INSTALL)
19+
install(
20+
TARGETS mmdblookup
21+
DESTINATION ${CMAKE_INSTALL_BINDIR}
22+
)
23+
endif()
2224
endif()

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Process this file with autoconf to produce a configure script.
33

44
AC_PREREQ([2.63])
5-
AC_INIT([libmaxminddb], [1.9.0], [[email protected]])
5+
AC_INIT([libmaxminddb], [1.10.0], [[email protected]])
66
AC_CONFIG_SRCDIR([include/maxminddb.h])
77
AC_CONFIG_HEADERS([config.h include/maxminddb_config.h])
88

doc/mmdblookup.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ mmdblookup --file [FILE PATH] --ip [IP ADDRESS] [DATA PATH]
99
# DESCRIPTION
1010

1111
`mmdblookup` looks up an IP address in the specified MaxMind DB file. The
12-
record for the IP address is displayed in a JSON-like structure with type
13-
annotations.
12+
record for the IP address is displayed with `{}` to denote maps and `[]` to
13+
denote arrays. The values are followed by type annotations. This output is
14+
_not_ JSON and is not intended to be used as such. If you need JSON, please
15+
see [`mmdbinspect`](https://github.com/maxmind/mmdbinspect).
1416

1517
If an IP's data entry resolves to a map or array, you can provide a lookup
1618
path to only show part of that data.

include/maxminddb_config.h.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define MAXMINDDB_CONFIG_H
33

44
#ifndef MMDB_UINT128_USING_MODE
5-
/* Define as 1 if we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */
5+
/* Define as 1 if we use unsigned int __attribute__ ((__mode__(TI))) for uint128 values */
66
#cmakedefine MMDB_UINT128_USING_MODE @MMDB_UINT128_USING_MODE@
77
#endif
88

include/maxminddb_config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define MAXMINDDB_CONFIG_H
33

44
#ifndef MMDB_UINT128_USING_MODE
5-
/* Define as 1 if we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */
5+
/* Define as 1 if we use unsigned int __attribute__ ((__mode__(TI))) for uint128 values */
66
#define MMDB_UINT128_USING_MODE 0
77
#endif
88

src/maxminddb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
#endif
2424
#include <windows.h>
2525
#include <ws2ipdef.h>
26+
#ifndef SSIZE_MAX
2627
#define SSIZE_MAX INTPTR_MAX
28+
#endif
2729
typedef ADDRESS_FAMILY sa_family_t;
2830
#else
2931
#include <arpa/inet.h>
@@ -945,7 +947,7 @@ static int find_address_in_search_tree(const MMDB_s *const mmdb,
945947
return MMDB_UNKNOWN_DATABASE_FORMAT_ERROR;
946948
}
947949

948-
uint32_t value = 0;
950+
uint64_t value = 0;
949951
uint16_t current_bit = 0;
950952
if (mmdb->metadata.ip_version == 6 && address_family == AF_INET) {
951953
value = mmdb->ipv4_start_node.node_value;
@@ -959,6 +961,7 @@ static int find_address_in_search_tree(const MMDB_s *const mmdb,
959961
uint8_t bit =
960962
1U & (address[current_bit >> 3] >> (7 - (current_bit % 8)));
961963

964+
// Note that value*record_info.record_length can be larger than 2**32
962965
record_pointer = &search_tree[value * record_info.record_length];
963966
if (record_pointer + record_info.record_length > mmdb->data_section) {
964967
return MMDB_CORRUPT_SEARCH_TREE_ERROR;

t/maxmind-db

Submodule maxmind-db updated 72 files

t/metadata_t.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
void test_metadata(MMDB_s *mmdb, const char *mode_desc) {
44
cmp_ok(mmdb->metadata.node_count,
55
"==",
6-
37,
7-
"node_count is 37 - %s",
6+
163,
7+
"node_count is 163 - %s",
88
mode_desc);
99
cmp_ok(mmdb->metadata.record_size,
1010
"==",
@@ -197,7 +197,7 @@ void test_metadata_as_data_entry_list(MMDB_s *mmdb, const char *mode_desc) {
197197
if (strcmp(key_name, "node_count") == 0) {
198198
MMDB_entry_data_list_s *value = entry_data_list =
199199
entry_data_list->next;
200-
cmp_ok(value->entry_data.uint32, "==", 37, "node_count == 37");
200+
cmp_ok(value->entry_data.uint32, "==", 163, "node_count == 163");
201201
} else if (strcmp(key_name, "record_size") == 0) {
202202
MMDB_entry_data_list_s *value = entry_data_list =
203203
entry_data_list->next;

0 commit comments

Comments
 (0)