Skip to content

Commit e6e8398

Browse files
authored
Merge pull request #197 from maxmind/greg/eng-1832
Correctly handle null check of entry_data_list
2 parents 2bc6b70 + 2faec63 commit e6e8398

File tree

7 files changed

+20
-24
lines changed

7 files changed

+20
-24
lines changed

.github/workflows/clang-analyzer.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ jobs:
2828
python-version: 3.13
2929

3030
- name: Install dependencies
31-
run: |
32-
python -m pip install --upgrade pip
33-
pip install setuptools wheel
31+
run: python -m pip install uv
3432

3533
- name: Build and run analyzer
3634
# We exclude extension/libmaxminddb/ as libmaxminddb has its own workflow
3735
# for this and we are not able to correct any issues with that code here.
38-
run: scan-build --exclude extension/libmaxminddb/ --status-bugs python setup.py build
36+
run: scan-build --exclude extension/libmaxminddb/ --status-bugs uv build
3937
env:
4038
CFLAGS: "-Werror -Wall -Wextra"
4139
MAXMINDDB_REQUIRE_EXTENSION: 1

.github/workflows/codeql-analysis.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ jobs:
4848
# uses a compiled language
4949

5050
- name: Install dependencies
51-
run: |
52-
python -m pip install --upgrade pip
53-
pip install setuptools wheel
51+
run: python -m pip install uv
5452

55-
- run: python setup.py build
53+
- run: uv build
5654
env:
5755
MAXMINDDB_REQUIRE_EXTENSION: 1
5856

.github/workflows/test-libmaxminddb.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Install dependencies
4141
run: |
4242
python -m pip install --upgrade pip
43-
pip install setuptools tox tox-gh-actions wheel
43+
pip install setuptools tox tox-gh-actions uv wheel
4444
4545
4646
- name: Install libmaxminddb
@@ -58,7 +58,7 @@ jobs:
5858
echo "LDFLAGS=-L/opt/homebrew/lib" >> "$GITHUB_ENV"
5959
6060
- name: Build with Werror and Wall
61-
run: python setup.py build
61+
run: uv build
6262
env:
6363
CFLAGS: "${{ env.CFLAGS }} -Werror -Wall -Wextra"
6464

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.so
55
*.sw?
66
*~
7+
.clangd
78
.coverage
89
.eggs
910
.idea

HISTORY.rst

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ History
1111
* The vendored ``libmaxminddb`` has been updated to 1.12.2.
1212
* The C extension now checks that the database metadata lookup was
1313
successful.
14+
* A theoretical segmentation fault with the C extension when doing lookups
15+
on a corrupt or invalid database was fixed.
1416

1517
2.6.3 (2025-01-09)
1618
++++++++++++++++++

extension/maxminddb.c

+2-8
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,7 @@ static PyObject *from_map(MMDB_entry_data_list_s **entry_data_list) {
751751
const uint32_t map_size = (*entry_data_list)->entry_data.data_size;
752752

753753
uint32_t i;
754-
// entry_data_list cannot start out NULL (see from_entry_data_list). We
755-
// check it in the loop because it may become NULL.
756-
// coverity[check_after_deref]
757-
for (i = 0; i < map_size && entry_data_list; i++) {
754+
for (i = 0; i < map_size && *entry_data_list; i++) {
758755
*entry_data_list = (*entry_data_list)->next;
759756

760757
PyObject *key = PyUnicode_FromStringAndSize(
@@ -792,10 +789,7 @@ static PyObject *from_array(MMDB_entry_data_list_s **entry_data_list) {
792789
}
793790

794791
uint32_t i;
795-
// entry_data_list cannot start out NULL (see from_entry_data_list). We
796-
// check it in the loop because it may become NULL.
797-
// coverity[check_after_deref]
798-
for (i = 0; i < size && entry_data_list; i++) {
792+
for (i = 0; i < size && *entry_data_list; i++) {
799793
*entry_data_list = (*entry_data_list)->next;
800794
PyObject *value = from_entry_data_list(entry_data_list);
801795
if (value == NULL) {

pyproject.toml

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[build-system]
2-
requires = ["setuptools>=68.2.2", "setuptools-scm", "wheel"]
3-
build-backend = "setuptools.build_meta"
4-
51
[project]
62
name = "maxminddb"
73
version = "2.6.3"
@@ -11,13 +7,12 @@ authors = [
117
]
128
requires-python = ">=3.9"
139
readme = "README.rst"
14-
license = {text = "Apache License, Version 2.0"}
10+
license = "Apache-2.0"
1511
classifiers = [
1612
"Development Status :: 5 - Production/Stable",
1713
"Environment :: Web Environment",
1814
"Intended Audience :: Developers",
1915
"Intended Audience :: System Administrators",
20-
"License :: OSI Approved :: Apache Software License",
2116
"Programming Language :: Python",
2217
"Programming Language :: Python :: 3",
2318
"Programming Language :: Python :: 3.9",
@@ -46,6 +41,14 @@ lint = [
4641
"ruff>=0.11.6",
4742
]
4843

44+
[build-system]
45+
requires = [
46+
"setuptools>=77.0.3",
47+
"setuptools-scm",
48+
"wheel",
49+
]
50+
build-backend = "setuptools.build_meta"
51+
4952
[tool.setuptools.package-data]
5053
maxminddb = ["py.typed"]
5154

0 commit comments

Comments
 (0)