mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Fix a memory leak when parsing a ns
Adding the same vote to a networkstatus consensus leads to a memory leak on the client side. Fix that by only using the first vote from any given voter, and ignoring the others. Problem found by Rotor, who also helped writing the patch. Thanks!
This commit is contained in:
@@ -2509,6 +2509,14 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
|
||||
} else {
|
||||
if (tok->object_size >= INT_MAX)
|
||||
goto err;
|
||||
/* We already parsed a vote from this voter. Use the first one. */
|
||||
if (v->signature) {
|
||||
log_fn(LOG_PROTOCOL_WARN, LD_DIR, "We received a networkstatus "
|
||||
"that contains two votes from the same voter. Ignoring "
|
||||
"the second vote.");
|
||||
continue;
|
||||
}
|
||||
|
||||
v->signature = tor_memdup(tok->object_body, tok->object_size);
|
||||
v->signature_len = (int) tok->object_size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user