mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 12:23:32 +01:00
Detect an unlikely integer overflow.
This commit is contained in:
parent
9e65e7a36f
commit
b058f64cc0
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,4 +11,6 @@
|
||||
/** A signed integer representing a country code. */
|
||||
typedef int16_t country_t;
|
||||
|
||||
#define COUNTRY_MAX INT16_MAX
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user