36 ms·
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 immens
by userbinator 6y ago
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.
- lmm 6y agoIt 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.
- jmgao 6y ago> 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.
- asddubs 6y agoyeah 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
- nullc 6y agoActually 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.
- marcan_42 6y agoThat'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.
- admax88q 6y agoI 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.
- userbinator 6y agoGood example of how a little insecurity is sometimes a good thing.