News for hackers. Stuff that matters.
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by kvuj on Thursday November 19, 2026 @10:24PM (#50569772)
> EVP_EncodeBlock() encodes a full block of input data in f and of length dlen and stores it in t. For every 3 bytes of input provided 4 bytes of output data will be produced. If dlen is not divisible by 3 then the block is encoded as a final block of data and the output is padded such that it is always divisible by 4. Additionally a NUL terminator character will be added. For example if 16 bytes of input data is provided then 24 bytes of encoded data is created plus 1 byte for a NUL terminator (i.e. 25 bytes in total). The length of the data generated without the NUL terminator is returned from the function.

My god, you only see this type of horrendous API in C don't you.

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...

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by td521534f12 on Thursday November 19, 2026 @11:02PM (#50570002)
"No way to prevent this" say users of only language where this regularly happens

https://xeiaso.net/blog/series/no-way-to-prevent-this/

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by cesarb on Friday November 20, 2026 @12:29AM (#50570526)
> My god, you only see this type of horrendous API in C don't you.

This is the appropriate place to put a link to this pair of classics on API design:

"How Do I Make This Hard to Misuse?" https://ozlabs.org/~rusty/index.cgi/tech/2008-03-30.html

"What If I Don't Actually Like My Users?" https://ozlabs.org/~rusty/index.cgi/tech/2008-04-01.html

Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by cowlevel on Friday November 20, 2026 @08:15AM (#50574226)
gets belongs in category -10
Re:OpenSSL: Buffer overflow in EVP_EncodeBlock() (CVE-2026-1... by Ekaros on Friday November 20, 2026 @03:17AM (#50571677)
It makes lot of sense when you think what encoding here does. Changes 3 arbitrary bytes to 4 bytes with only some values being possible. Null termination is one issue, but the output is a string such only length of the text itself makes sense.