Memcmp being wrongly stripped like strcmp(gcc.gnu.org)
gcc.gnu.org
Memcmp being wrongly stripped like strcmp
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
6 comments
This is a really good example of how to report, and respond to a bug.
The tooling is also interesting -- bugzilla and CVS.
Edit: my mistake its actually git underneath.
Edit: my mistake its actually git underneath.
Wow. This failure case of a compiler almost looks like the same sort of nonsense that AI/neural networks can generate, no doubt caused similarly by their immense complexity. The common theme is that no sane human would even think of generating such output.
It seems a pretty straightforward (and all-too-common) kind of misunderstanding between humans: one person gave a function used by both memcmp and strcmp a name to do with strcmp, then another person wrote a comment that talked about strcmp, and eventually a third person made a change that would have been valid if the function was used only by strcmp. No individual would make such a mistake, true, but an organisation of several people could easily fail in the same way.
> No individual would make such a mistake, true, but an organisation of several people could easily fail in the same way.
You might be able to claim that it's unlikely for someone to make this mistake if the changes were in one single change (I doubt even this!), but the same person revisiting code at multiple points in time might as well be different people.
You might be able to claim that it's unlikely for someone to make this mistake if the changes were in one single change (I doubt even this!), but the same person revisiting code at multiple points in time might as well be different people.
yeah I've definitely made equivalent mistakes like that, where I gave something a misleading name because I didn't spend enough time thinking about it, and then eventually confused myself into introducing a bug
Actually this is a common sort of bug I've seen programmers implement, e.g. using strcpy where memcpy should be used or vice versa. Most common on interface boundaries with other languages, particular "everything is a string" languages.
So it's not that shocking to see a similar sort of bug made inside the compiler.
So it's not that shocking to see a similar sort of bug made inside the compiler.
That's how the Wii got pwned. They were comparing binary SHA-1 hashes in RSA signatures with strncmp.
They also weren't checking padding, so you didn't have to use a real signature with a 00 byte in a convenient place (though I did find one), but rather could just use an all-00 signature, because performing the RSA computation on zero yields zero.
They also weren't checking padding, so you didn't have to use a real signature with a 00 byte in a convenient place (though I did find one), but rather could just use an all-00 signature, because performing the RSA computation on zero yields zero.
I wonder how many bugs C strings have been responsible for, all because storing a null byte at the end seems more efficient than storing a length up front.
Good example of how a little insecurity is sometimes a good thing.
[deleted]
mrtnmcc(6)
nurettin(1)