8 ms·
Glancing over the patch, this appears to be the crucial part: size_needed = (sizeof (*host_addr) - + sizeof (*h_addr_ptrs) +
by userbinator 12y ago
Glancing over the patch, this appears to be the crucial part:
size_needed = (sizeof (*host_addr)
- + sizeof (*h_addr_ptrs) + strlen (name) + 1);
+ + sizeof (*h_addr_ptrs)
+ + sizeof (*h_alias_ptr) + strlen (name) + 1);
Doesn't it seem disappointing that some programmers, for whatever reason, just can't seem to count correctly?
- rdtsc 12y agoIt is nice if they can count. However instead of sending them back to kindergarten, it might make sense to find a compiler/language/framework that would make inability to count not result in easy remote exploits.
- peterwwillis 12y agoSo remove the ability to use pointers to directly access memory. Then you're only left with all of the other security vulnerabilities found in every such language.
- pjmlp 12y agoIt would still be an improvement.
- AgentME 12y agoUh, how often do code execution vulnerabilities show up in non-C programs compared to how often they show up in C programs?
- Ded7xSEoPKYNsDd 12y agoAll the time: SQLi, XSS, arbitrary file upload, ...
- tedunangst 12y agoThe fun part is that when you find a language/framework that (e.g.) deserializes data by running eval(), it's so much easier to write portable exploits. 32 bit, 64 bit, x86, arm, mips, aslr? None of that matters. Literally eval(system("/bin/sh")) and done.
- MichaelGG 12y agoXSS is a totally different level. When's the last time a bunch of networked devices needed patches because of XSS? And even if these problems were as widespread, eliminating a huge class of errors is a big step up. Nearly every serious vulnerability in Microsoft's code for the past years is from memory unsafeness. Hell, why bother with malaria or smallpox vaccines, since people just die from something else anyways.
- peterwwillis 12y agoThe answer to your question is "all the time", because most new appliances are using more high level languages and xss-prone interfaces. This also ignores all the ones that don't get found/fixed. Of course we should work to eliminate problems, but you have to consider the bigger picture and whether abandoning the language is worth it. So far the pros outweigh the few unique cons.
- cm2187 12y agoWithout trolling, it is true that string manipulation has been a fertile source of major bugs. I don't really see the benefit of having to manipulate arrays of characters manually instead of a string datatype. An unmanaged language doesn't really gain anything from this, apart from this sort of embarrassment.
- lmm 12y agoNot really. h_addr_ptrs and h_alias_ptr look very similar, and that style with the random linebreaks is practically begging for this kind of error. I'm far more disappointed that so many programmers haven't adopted better systems, systems that avoid the possibility of this kind of error entirely.
- tedunangst 12y agoUnless I've misread the patch, the problem isn't that they counted the sizeof the wrong thing, it's that they forgot one of the things entirely. sizeof() the same thing twice would have been explained by similar names.
- pjmlp 12y ago> Doesn't it seem disappointing that some programmers, for whatever reason, just can't seem to count correctly? Yet there seems to exist this belief in the C world, that they can.
- IshKebab 12y agoYeah, "I would have written it right."
- sp332 12y agoThere are only 2 really difficult problems in computer science: cache invalidation, naming things, and off-by-one errors.
- mikeash 12y agoI have no idea if it would apply here, but many instances where a field is forgotten in a size calculation happen because the field wasn't originally there, and not all of the relevant code got updated when it was added. Beware any code that requires knowledge of all elements of some set, and still compiles if a new element is added and the code isn't updated for it.
- mserdarsanli 12y agoCounting is the hardest thing in programming.
- MichaelGG 12y agoI find it pretty funny how no matter how many times we're shown that unsafe languages blow up on all sorts of code by all sorts of programmers, anyone would still try to defend the language. FFS in this case they even found the bug and fixed it, but didn't notice how it could be a vulnerability. So even with eyes directly on issues, we (human programmers excluding djb) can't seem to get it right.
- indymike 12y agoReason why people defend unsafe languages: If you make it idiot-proof, someone will make a better idiot.
- MichaelGG 12y agoCare to point out all the RCEs that exist in the millions of lines of C# and Java out there? Apart from exec/eval I don't recall seeing a single one (I'm sure there's a few where they interop or use unsafe code.)
- kevinr 12y agohttp://www.cvedetails.com/vulnerability-list/vendor_id-45/product_id-6117/opec-1/Apache-Struts.html http://www.cvedetails.com/vulnerability-list/vendor_id-45/pr... That's 12 just in one of the more popular Java web frameworks. RCE is possible in any language.
- MichaelGG 12y agoThose appear to be all exec/eval type bugs. Yes, if you do "eval($querystring)" you've got a problem in any language, including C.
- AnthonyMouse 12y ago> I find it pretty funny how no matter how many times we're shown that unsafe languages blow up on all sorts of code by all sorts of programmers, anyone would still try to defend the language. Heartbleed, Shellshock, Ghost. OpenSSL implemented their own memory allocator, so you would get the same result in another language. Shellshock was a parsing failure, memory safety had nothing to do with it, still arbitrary code execution. Ghost is very hard to exploit, which is why people didn't notice how it could be. It's like trying to exploit an off by one error. Bugs in production code are not "safe" regardless of what language you use. What we need are better ways to find bugs before the code is put into production.