Live data from Hacker News

C99 doesn't need function bodies, or 'VLAs are Turing complete'

lemon.rip

101–110 of 257 posts

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#101

I haven't thought about C in years - that one where author passes in a printf as a char array element and de-references it to execute it ... gives me chills. Y'all kids have fun - Im going to stick with my VM over here and call it a day. This makes even modern JS look sane by comparison. Excellent write up too.

> I haven't thought about C in years ... Im going to stick with my VM over here and call it a day.

What's your VM written in?

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#102
post #98
post #71

Earlier quoted context omitted.

> What about not adding even more ways how we should avoid using C? That's a mute point for C's target audience because they already understand that they need to be mindful of what the language does.

That is like saying if sushi knifes are already sharp enough, there is no issue cutting fish with a samurai sword instead, except at least with the knife maybe the damage isn't as bad.

I like your comparison of a C programmer with a samurai.

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#103
post #9

This kind of insanity is exactly why I don't use stuff like C anymore. It's a landmark and incredible language, but it's chock full of potholes and foot-shotguns (footguns that blow off your entire leg). Even huge companies can't get it right, which makes sense. It started as a language basically without guardrails, and because of the extreme deference to the holy backward compatibility, it's more or less always goin…

C has many problems, but I don't see this as one. Very few people even realize this functionality exists, and I don't see anyone promoting its use.

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#104
post #96
post #82

Earlier quoted context omitted.

VLAs make it a lot easier to corrupt the stack by accident. Unless you're quite a careful coder, stuff like: f (size_t n) { char str[n]; leads to a possible exploit where the input is manipulated so n is large, causing a DoS attack (at best) or full exploit at worse. I'm not saying that banning VLAs solves every problem though. However the main reason we forbid VLAs in all our code is because thread stacks (particula…

You shouldn't be writing C if you're not a careful coder.

And if you're a careful coder writing C, you should give the VLA the stink eye unless it's proving its worth.

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#105
post #71
post #40

Earlier quoted context omitted.

What about not adding even more ways how we should avoid using C?

> What about not adding even more ways how we should avoid using C? That's a mute point for C's target audience because they already understand that they need to be mindful of what the language does.

What the heck. It's "moot", not "mute".

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#106
post #98
post #71

Earlier quoted context omitted.

> What about not adding even more ways how we should avoid using C? That's a mute point for C's target audience because they already understand that they need to be mindful of what the language does.

That is like saying if sushi knifes are already sharp enough, there is no issue cutting fish with a samurai sword instead, except at least with the knife maybe the damage isn't as bad.

The difference between the largest sushi knives and a katana is more about who wields them than the blade involved.

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#107
post #96
post #82

Earlier quoted context omitted.

VLAs make it a lot easier to corrupt the stack by accident. Unless you're quite a careful coder, stuff like: f (size_t n) { char str[n]; leads to a possible exploit where the input is manipulated so n is large, causing a DoS attack (at best) or full exploit at worse. I'm not saying that banning VLAs solves every problem though. However the main reason we forbid VLAs in all our code is because thread stacks (particula…

You shouldn't be writing C if you're not a careful coder.

Yeah, right.

https://msrc-blog.microsoft.com/2019/07/16/a-proactive-appro...

https://research.google/pubs/pub46800/

https://support.apple.com/guide/security/memory-safe-iboot-i...

Maybe you could give an helping hand to Microsoft, Apple and Google, they are in need of carefull C coders.

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#108
post #98

Earlier quoted context omitted.

That is like saying if sushi knifes are already sharp enough, there is no issue cutting fish with a samurai sword instead, except at least with the knife maybe the damage isn't as bad.

I like your comparison of a C programmer with a samurai.

Including that most of them end up doing Seppuku on their applications.

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#109
post #98

Earlier quoted context omitted.

That is like saying if sushi knifes are already sharp enough, there is no issue cutting fish with a samurai sword instead, except at least with the knife maybe the damage isn't as bad.

The difference between the largest sushi knives and a katana is more about who wields them than the blade involved.

One ends up cutting quite a few pieces either way.

Re: C99 doesn't need function bodies, or 'VLAs are Turing complete'

#110

I haven't thought about C in years - that one where author passes in a printf as a char array element and de-references it to execute it ... gives me chills. Y'all kids have fun - Im going to stick with my VM over here and call it a day. This makes even modern JS look sane by comparison. Excellent write up too.

That printf exploit is quite impressive I think.
Post reply on HN