Hacker News new | ask | show | jobs
by Joker_vD 11 days ago
Have you seen the wave of recent Whatever2Shell CVEs? Several of them happened precisely because "a type that could only represent positive integers" was used for the sizes.
2 comments

I don't think that's what he's talking about. The problem with those CVEs is an unsigned type with default wrap semantics. But it need not be like that. Look at how Ada allows user-defined integers.
The user-defined integer types in Ada are either a subrange of the signed integers, or have modular semantics exactly as that that "unsigned T" have in C/C++. If we're talking about the additional range checks, they're only performed on an assignment to a variable. So, no, I don't exactly see how Ada's semantics would help here.
I think it's because of the overflow behavior of the types/operators used, not so much the fact that they only represent positive integers.