News for hackers. Stuff that matters.
Re:The expected value of the game is positive regardless of ... by Lockal on Friday September 06, 2024 @03:15PM (#41468906)
If a second party can submit adversarial values into a system, potentially causing a denial of service in a binary search (where comparisons are computationally expensive and data is unevenly distributed), there is a much simpler solution: avoid using sorted collections and binary search. Instead, use hashmaps. To address similar HashDoS attacks, many implementations (in Python, Rust, Java, etc.) use a randomized hash function, which vaguely resembles the idea of randomizing starting value for binary search.

There are no comments on this comment yet.