News for hackers. Stuff that matters.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by userbinator on Thursday November 19, 2026 @10:29PM (#50569799)
What's "horrendous"? I don't see anything which stands out as being wrong. It specifies exactly the lengths of input and output.

gets(), on the other hand, that is "horrendous".

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by kvuj on Thursday November 19, 2026 @10:33PM (#50569818)
Perhaps I'm just used to having programmed in C# professionally for a little bit, but these sorts of APIs where you have to do a calculation to determine the destination buffer size make me feel like a caveman. A minuscule typo and you get a CVE like this.

I know, I know, C is low level and high performance, but surely in the year of our lord 2026, we could have come out with something simpler.

Horrendous is a strong word, you're right.

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by JSR_FDED on Friday November 20, 2026 @12:49AM (#50570647)
You should be comparing with assembly language, not C#.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by uecker on Friday November 20, 2026 @01:06AM (#50570768)
One can abstract buffer handling away in C just fine, eliminating all those problems. I don't know why programmers insist on open-coding low-level buffer management.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by eptcyka on Friday November 20, 2026 @01:28AM (#50570884)
Yes, of course, this isn’t C, this is just another case of people writing C wrong.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by stavros on Friday November 20, 2026 @04:10AM (#50572087)
Perhaps we could use another language, where it's not so easy (or possible) to write it wrong?
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by uecker on Friday November 20, 2026 @11:39AM (#50577484)
It is also easy to write it wrong.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by pjmlp on Friday November 20, 2026 @02:26AM (#50571304)
Not even that is usable as excuse, only those that never tried out the systems programming languages that either predated C, or where equally developed during the 1970's outside Bell Labs and UNIX ecosystem.

You could have come with something simpler in PL/I.

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by Ono-Sendai on Friday November 20, 2026 @03:46AM (#50571914)
The proper way to do it is to factor out the length calc into a utility function that the API provides. Also the calculated buffer length is passed in to the function, and an error is returned if it's too small.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by amluto on Thursday November 19, 2026 @11:10PM (#50570049)
Even in C, if you have a function that takes an input buffer and output buffer of differing lengths, the right API has the caller pass both lengths.

But yes, gets is worse.

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by userbinator on Thursday November 19, 2026 @11:57PM (#50570346)
takes an input buffer and output buffer of differing lengths, the right API has the caller pass both lengths.

If there is no fixed relationship between the two, then that makes sense; but in this case there is a very simple and well-defined relationship between them. But to specify two lengths which must always agree; and if not, then what? You've effectively invented an additional artificial error condition, an additional branch, and burdened all the callers up the chain to do something, which is a treacherous path to complexity and the production of even more bugs.

Or are you just preaching the same mindless idiocy that lead to Microsoft's memcpy_s() (the "s" is for "stupid")?

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by baq on Friday November 20, 2026 @02:48AM (#50571446)
The artificial error condition is the whole point and the hoops you have to jump through to be able to reach it as you say are reasons to not use C because it’s hard to enforce invariants like this and easy to ignore them with mostly working code. Mostly working was fine last year, it isn’t anymore.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by IanCal on Friday November 20, 2026 @02:28AM (#50571317)
The thing that jumps out to me is that it returns “the size of the output data minus one” but if I’m passing in a pointer it’s on me to make sure there’s enough memory allocated isn’t it? So the caller must make sure it’s calculated this correctly - in which case why return the size? Taking the size as an argument could be safer as you’d be checking the caller calculated enough space too.

(Honest questions in this it’s probably been 20 years since I did c)

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by zzril on Friday November 20, 2026 @05:04AM (#50572521)
That part of the API seems particularly random indeed, especially when comparing it to other EVP_{En,De}code* functions which use the returned int for success/error.

The only reason for such a design I could think of is that the caller would be able to "detect" the overflow by comparing the returned value against the length of the buffer. But that is of course pointless, as the compiler is free to assume a buffer overflow cannot happen and thus optimize the check away...