News for hackers. Stuff that matters.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by reillyrider on Friday November 20, 2026 @05:04AM (#50572522)
Why would anyone prefer signed for indexing and sizes?

With unsigned you only need one check: 'i < bound', it works always, regardless how i is computed, and it doesn't matter if the calculation overflowed or wrapped around, still works.

With signed you need: 'i >= 0 && i < bound', and you need to be very careful how you calculate i because overflow is undefined behavior.

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by dbaupp on Friday November 20, 2026 @07:18AM (#50573693)
The issue with accidental overflow leading to wrap-around is also relevant to the value of `bound`.

If `bound` is unsigned and experiences accidental wrap-around due to underflow, the simple `i < bound` check fails open: most values of i pass against the unintentionally-huge `bound`. The signed version fails closed (no i passes both i >= 0 and i < bound), which is usually safer.

That’s how the argument goes, anyway. You’re right that using signed means a missing `>= 0` check can be a problem, as well as all the risks of signed-overflow UB.

No perfect solution in C.

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by uecker on Friday November 20, 2026 @11:41AM (#50577532)
The N >= 0 check you often get automatically using sanitizers, e.g. when using an array [N] somewhere, or by concerting to size_t at last moment and then getting a size which is so big that allocation is guaranteed to fail.

Not that are wraparound CVEs in Rust as well, so there is no perfect solution even outside of C.