Remix.run Logo
▲ uecker 2 hours ago

Why unrealistic? I was in the unsigned camp a long time ago and switched to signed types for indexing and sizes, and this made many problems go a way.

There was just a nginx issue that highlights how problematic the use of unsigned is in this context: CVE -2026-123007

▲wahern 13 minutes ago | parent [-]

From a brief look, I'd say there were several wrong turns made that led to the CVE-2026-123007 overflow bug.

For why I think it's unrealistic to go all-in on signed integers in C, it's because sizeof is unsigned, and most APIs dealing with lengths use size_t, and there are many pitfalls when mixing signed and unsigned types.

But I agree that there's a good case for using signed for the task behind that CVE. As I said, there are compelling reasons.

OpenSSL is a case study in the pitfalls with mixing signed and unsigned in C code. A major reason is the careful dance it has to do mixing signed and unsigned, and it stumbles. There's no substitute for thinking long and hard about your arithmetic, and at least for me, when I expend that effort I also tend to use overflow checking APIs, clamping, etc. Do that and the benefits of signed start to disappear, or at least the debate starts to lose relevance. Why OpenSSL doesn't create and use a set of overflowing checking routines is beyond me as it would simplify an incredible amount of very hairy and brittle code.