|
|
|
|
|
by vardump
3708 days ago
|
|
Say you're computing a buffer size with untrusted inputs. With saturated arithmetic, you could add the (unsigned) sizes together without a possibility of an overflow, so you could eliminate all except the last range check (=branch). If the end result is larger than what is reasonable, return an error. It's not possible that the value wrapped around and later code will be writing to unallocated memory. |
|