aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2018-03-10 19:23:17 +0100
committerGerald Combs <gerald@wireshark.org>2018-03-11 02:08:28 +0000
commit2a9097046e51d67794780bb57e94229e769fc01b (patch)
tree17b04d898fc3d86a493eaa9c684b6edb9d5bff0b
parentab7fbb73951716ee08406fc1a51fc522da2c420d (diff)
maxmind: use ws_strtou32 to convert AS numbers.
Change-Id: I0578f8a674feee6e4763d5481a2285b7b2a054dc Reviewed-on: https://code.wireshark.org/review/26416 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--epan/maxmind_db.c10
-rw-r--r--epan/maxmind_db.h2
2 files changed, 8 insertions, 4 deletions
diff --git a/epan/maxmind_db.c b/epan/maxmind_db.c
index 93b5a15ce0..484be7f355 100644
--- a/epan/maxmind_db.c
+++ b/epan/maxmind_db.c
@@ -33,6 +33,7 @@ static mmdb_lookup_t mmdb_not_found;
#include <wsutil/file_util.h>
#include <wsutil/filesystem.h>
#include <wsutil/ws_pipe.h>
+#include <wsutil/strtoi.h>
// To do:
// - If we can't reliably do non-blocking reads, move process_mmdbr_stdout to a worker thread.
@@ -174,9 +175,12 @@ process_mmdbr_stdout(void) {
} else if (g_str_has_prefix(line, RES_ASN_ORG)) {
cur_lookup.found = TRUE;
cur_lookup.as_org = chunkify_string(val_start);
- } else if (g_str_has_prefix(line, RES_ASN_NUMBER)) {
- cur_lookup.found = TRUE;
- cur_lookup.as_number = (unsigned int) strtoul(val_start, NULL, 10);
+ } else if (val_start && g_str_has_prefix(line, RES_ASN_NUMBER)) {
+ if (ws_strtou32(val_start, NULL, &cur_lookup.as_number)) {
+ cur_lookup.found = TRUE;
+ } else {
+ MMDB_DEBUG("Invalid as number: %s", val_start);
+ }
} else if (g_str_has_prefix(line, RES_LOCATION_LATITUDE)) {
cur_lookup.found = TRUE;
cur_lookup.latitude = g_ascii_strtod(val_start, NULL);
diff --git a/epan/maxmind_db.h b/epan/maxmind_db.h
index 1c3ade02bc..0c2091e434 100644
--- a/epan/maxmind_db.h
+++ b/epan/maxmind_db.h
@@ -26,7 +26,7 @@ typedef struct _mmdb_lookup_t {
const char *country;
const char *country_iso;
const char *city;
- unsigned int as_number;
+ guint32 as_number;
const char *as_org;
double latitude;
double longitude;