diff options
author | Gerald Combs <gerald@wireshark.org> | 2018-03-13 11:52:03 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2018-03-13 21:14:46 +0000 |
commit | 2a227f72bf4d9f06843a6432a50a4b89da74bff6 (patch) | |
tree | 893118a41cb58499e74d0ff9fea4257eac5236eb /epan/maxmind_db.c | |
parent | 246f0bc0125eb2137781f5f8bfad783a2f7ac4cd (diff) |
Properly initialize mmdb_lookup_t.
Set our initial geographic coordinates to DBL_MAX, otherwise we might
give people the wrong impression about the PIRATA weather buoy at 0°0'0"
N 0°0'0" E.
Change-Id: I34683883ef02c4fe40d5d93a7695d0cca277345c
Reviewed-on: https://code.wireshark.org/review/26463
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/maxmind_db.c')
-rw-r--r-- | epan/maxmind_db.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/epan/maxmind_db.c b/epan/maxmind_db.c index 033b76dcc1..1151801a98 100644 --- a/epan/maxmind_db.c +++ b/epan/maxmind_db.c @@ -127,6 +127,11 @@ static const void *chunkify_v6_addr(const ws_in6_addr *addr) { return chunk_v6_bytes; } +static void init_lookup(mmdb_lookup_t *lookup) { + mmdb_lookup_t empty_lookup = { FALSE, NULL, NULL, NULL, 0, NULL, DBL_MAX, DBL_MAX }; + *lookup = empty_lookup; +} + static gboolean process_mmdbr_stdout(void) { @@ -157,11 +162,11 @@ process_mmdbr_stdout(void) { // [init] or resolved address in square brackets. line[line_len - 1] = '\0'; g_strlcpy(cur_addr, line + 1, WS_INET6_ADDRSTRLEN); - memset(&cur_lookup, 0, sizeof(cur_lookup)); + init_lookup(&cur_lookup); } else if (strcmp(line, RES_STATUS_ERROR) == 0) { // Error during init. cur_addr[0] = '\0'; - memset(&cur_lookup, 0, sizeof(cur_lookup)); + init_lookup(&cur_lookup); mmdb_resolve_stop(); } else if (val_start && g_str_has_prefix(line, RES_COUNTRY_ISO_CODE)) { cur_lookup.found = TRUE; @@ -205,7 +210,7 @@ process_mmdbr_stdout(void) { } } cur_addr[0] = '\0'; - memset(&cur_lookup, 0, sizeof(cur_lookup)); + init_lookup(&cur_lookup); } } |