News for hackers. Stuff that matters.
Re:Don't run 'strings' on untrusted files by WalterBright on Saturday October 25, 2014 @03:41PM (#8509155)
As I wrote some time ago,

http://www.drdobbs.com/architecture-and-design/cs-biggest-mi...

it is easy to add bounds checking arrays to the C language. The trouble is, nobody is interested in doing it.

It'd be a heckuva lot easier than changing languages.

Re:Don't run 'strings' on untrusted files by Animats on Sunday October 26, 2014 @03:17AM (#8510446)
(Bright, of course, is the creator of D.)

I agree completely about C. I've been saying this for years. There are three big problems that cause crashes in C programs: "How big is it?", "Who owns it?", and "Who locks it?". The result is over three decades of segfaults and buffer overflows.

There have been three or four variants on C which address some of those issues. I've proposed one myself. None got any traction. The only thing that might work is if someone developed a safe variant of C which could be machine-generated from existing C code, and didn't add significant overhead. GCC already has a fat-pointer subscript checking option, but nobody uses it. That approach is usually slow, with a subscript check on every reference. If you do it right, most subscript checks get hoisted out of loops. Go does that for many FOR statements.

Rust is one of the very few languages which addresses all three of those issues without resorting to garbage collection. I really hope the Rust crowd doesn't screw it up.

Re:Don't run 'strings' on untrusted files by WalterBright on Sunday October 26, 2014 @05:06AM (#8510589)
> GCC already has a fat-pointer subscript checking option, but nobody uses it

My experience with adding extensions to C++ is that nobody will use them, not even the people who proposed the extension, unless it is adopted by the Standard. The same goes for C.

The feature I proposed for C has been in D since the beginning, and has a very strong track record of success - both in user acceptance and in eliminating bugs. Whether the runtime bounds checking is actually done or not is controlled by a compiler switch - but most users choose to leave it on.

Re:Don't run 'strings' on untrusted files by dbaupp on Sunday October 26, 2014 @06:03AM (#8510682)
There are a lot of GCC extensions that are not in the standard. https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html

Things that are definitely used are __attribute__'s and labels-as-values.

Re:Don't run 'strings' on untrusted files by CamperBob2 on Saturday October 25, 2014 @03:55PM (#8509210)
How would that fix the problem at hand? The code in question isn't using array notation. At the end of the day, it's not a case of using C when another language would be better, it's a case of crappy coding.
Re:Don't run 'strings' on untrusted files by WalterBright on Saturday October 25, 2014 @04:03PM (#8509234)
It helps because instead of rewriting the whole app, just the function parameter types are redone where pointers to data are changed to bounds checked arrays, on a case by case basis.

It isn't a magic bullet, but as buffer overflows are (I presume) the most common cause of C security exploits, this would help a lot.

Re:Don't run 'strings' on untrusted files by CamperBob2 on Saturday October 25, 2014 @04:41PM (#8509322)
Maybe, but my fear would be that the act of rewriting it to use array notation will introduce yet more bugs. Some of the comments point out that the problem exists because nobody cared enough to fix it for several years. Having seen that nobody cared enough to fix it, it's not clear that anyone will care enough to fix it properly.