]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: fix geoip_mmdb backend MMDB_open error handling 16685/head
authorEnsar Sarajčić <dev@ensarsarajcic.com>
Fri, 19 Dec 2025 12:57:06 +0000 (13:57 +0100)
committerMiod Vallat <miod.vallat@powerdns.com>
Mon, 29 Dec 2025 10:58:24 +0000 (11:58 +0100)
According to [MMDB_open docs], errors from `MMDB_open` should be
compared to `MMDB_SUCCESS` (which is 0). All other errors are > 0, which
means that existing check never detects errors, causing further queries
to fail with error:
```
The MaxMind DB file is in a format this library can't handle
(unknown record size or binary format version)
```

[MMDB_open docs]: https://maxmind.github.io/libmaxminddb/#mmdb_open

Signed-off-by: Ensar Sarajčić <dev@ensarsarajcic.com>
(cherry picked from commit e1641d3872c48f4ec1ed11b775b5318322f2184a)

modules/geoipbackend/geoipinterface-mmdb.cc

index 95f1b56daf10284473908b790a7d9edb73da4865..5eb5b41d2ca050761267a818c573d22baeef7d41 100644 (file)
@@ -46,8 +46,9 @@ public:
     else
       throw PDNSException(string("Unsupported mode ") + modeStr + ("for geoipbackend-mmdb"));
     memset(&d_s, 0, sizeof(d_s));
-    if ((ec = MMDB_open(fname.c_str(), flags, &d_s)) < 0)
+    if ((ec = MMDB_open(fname.c_str(), flags, &d_s)) != MMDB_SUCCESS) {
       throw PDNSException(string("Cannot open ") + fname + string(": ") + string(MMDB_strerror(ec)));
+    }
     d_lang = language;
     g_log << Logger::Debug << "Opened MMDB database " << fname << "(type: " << d_s.metadata.database_type << " version: " << d_s.metadata.binary_format_major_version << "." << d_s.metadata.binary_format_minor_version << ")" << endl;
   }