diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-27 16:30:02 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-27 16:30:02 -0400 |
commit | b058f64cc002b44e6dd48616ca3163a01c3f3e14 (patch) | |
tree | 78416b0b0a96cf19e9bd8dff87c3eb03cb0d34ea /src/feature/stats/geoip_stats.c | |
parent | 9e65e7a36f6f7b18164d0e76fe25f0c32b31aaec (diff) | |
download | tor-b058f64cc002b44e6dd48616ca3163a01c3f3e14.tar.gz tor-b058f64cc002b44e6dd48616ca3163a01c3f3e14.zip |
Detect an unlikely integer overflow.
Diffstat (limited to 'src/feature/stats/geoip_stats.c')
-rw-r--r-- | src/feature/stats/geoip_stats.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/feature/stats/geoip_stats.c b/src/feature/stats/geoip_stats.c index 3e647bd46c..1a4f8ddfb0 100644 --- a/src/feature/stats/geoip_stats.c +++ b/src/feature/stats/geoip_stats.c @@ -265,7 +265,10 @@ geoip_note_client_seen(geoip_client_action_t action, int country_idx = geoip_get_country_by_addr(addr); if (country_idx < 0) country_idx = 0; /** unresolved requests are stored at index 0. */ - increment_v3_ns_request(country_idx); + IF_BUG_ONCE(country_idx > COUNTRY_MAX) { + return; + } + increment_v3_ns_request((country_t) country_idx); } } |