News for hackers. Stuff that matters.
Re:Memcmp being wrongly stripped like strcmp by userbinator on Friday October 09, 2020 @12:32AM (#24726849)
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.
Re:Memcmp being wrongly stripped like strcmp by lmm on Friday October 09, 2020 @01:35AM (#24727154)
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.
Re:Memcmp being wrongly stripped like strcmp by jmgao on Friday October 09, 2020 @01:42AM (#24727187)
> 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.

Re:Memcmp being wrongly stripped like strcmp by asddubs on Saturday October 10, 2020 @01:38AM (#24736894)
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
Re:Memcmp being wrongly stripped like strcmp by nullc on Friday October 09, 2020 @01:40AM (#24727178)
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.

Re:Memcmp being wrongly stripped like strcmp by marcan_42 on Friday October 09, 2020 @02:05AM (#24727283)
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.

Re:Memcmp being wrongly stripped like strcmp by admax88q on Friday October 09, 2020 @12:43PM (#24731712)
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.
Re:Memcmp being wrongly stripped like strcmp by userbinator on Saturday October 10, 2020 @03:34PM (#24741280)
Good example of how a little insecurity is sometimes a good thing.