mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Clear memory in smartlist_remove_keeporder.
The smartlist functions take great care to reset unused pointers inside the smartlist memory to NULL. The function smartlist_remove_keeporder does not clear memory in such way when elements have been removed. Therefore call memset after the for-loop that removes elements. If no element is removed, it is effectively a no-op. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
committed by
Nick Mathewson
parent
5a0c857996
commit
670d0f9f5b
@@ -0,0 +1,4 @@
|
||||
o Minor features (defense in depth):
|
||||
- In smartlist_remove_keeporder(), set any pointers that become
|
||||
unused to NULL, in case a bug causes them to be used later. Closes
|
||||
ticket 30176. Patch from Tobias Stoeckmann.
|
||||
@@ -177,6 +177,8 @@ smartlist_remove_keeporder(smartlist_t *sl, const void *element)
|
||||
sl->list[i++] = sl->list[j];
|
||||
}
|
||||
}
|
||||
memset(sl->list + sl->num_used, 0,
|
||||
sizeof(void *) * (num_used_orig - sl->num_used));
|
||||
}
|
||||
|
||||
/** If <b>sl</b> is nonempty, remove and return the final element. Otherwise,
|
||||
|
||||
Reference in New Issue
Block a user