Perfect usage of the title to get on HN frontpage.
I really expected this to be another aggressive Rust marketing peice at first
Let's Destroy C
91–100 of 192 posts
Re: Let's Destroy C
#92Earlier quoted context omitted.
By that same logic, puts("Hello, world!"); is also vulnerable to DoS attack and information leak since someone could have removed the NUL terminator at the end of the string and have puts() read uninitialized/unmapped memory. Which is absurd logic.
Format string attacks have occurred in the wild. [0] > Originally thought harmless, format string exploits can be used to crash a program or to execute harmful code. They are not the same as puts. Puts can allow you to potentially read memory. A format string attack can allow you to write to memory. [0] https://en.wikipedia.org/wiki/Uncontrolled_format_string
Re: Let's Destroy C
#93Earlier quoted context omitted.
That's a format string attack [0]. By modifying the start of that string, you can begin reading and writing to various parts of the stack. Whilst implementations may inline that string into a RO memory region - that's not defined behaviour, so you shouldn't depend on it. [0] https://owasp.org/www-community/attacks/Format_string_attack
> By modifying the start of that string In order to modify that string, even in RW pages, the attacker already has to have access, at which point the point is moot. It's like saying "if you can change memory, then you can change memory"....
printf("Hello, World!\n");
really any safer than this? printf("%s\n", "Hello, World!");Re: Let's Destroy C
#94Earlier quoted context omitted.
By that same logic, puts("Hello, world!"); is also vulnerable to DoS attack and information leak since someone could have removed the NUL terminator at the end of the string and have puts() read uninitialized/unmapped memory. Which is absurd logic.
Format string attacks have occurred in the wild. [0] > Originally thought harmless, format string exploits can be used to crash a program or to execute harmful code. They are not the same as puts. Puts can allow you to potentially read memory. A format string attack can allow you to write to memory. [0] https://en.wikipedia.org/wiki/Uncontrolled_format_string
Re: Let's Destroy C
#95Earlier quoted context omitted.
Can you explain why?
On C language an expression which evaluates to any non-zero value is considered as True. So for example this kind of statement would not likely behave as intended: if (TRUE == expression) { ... }
Re: Let's Destroy C
#96In this case, that language is the C Preprocessor, already well documented and widely accepted as a Bad Language To Start With.
The title of the article is misleading: it's not "destroying C" it's writing Bad Code using the C Preprocessor. It's not destroying C any more than a series of bad puns destroys the English language.
Re: Let's Destroy C
#97Earlier quoted context omitted.
Can you please exemplify how you exploit a printf("Hello, World!\n") ?
That's a format string attack [0]. By modifying the start of that string, you can begin reading and writing to various parts of the stack. Whilst implementations may inline that string into a RO memory region - that's not defined behaviour, so you shouldn't depend on it. [0] https://owasp.org/www-community/attacks/Format_string_attack
Re: Let's Destroy C
#98Re: Let's Destroy C
#99C has its place; every language has its quirks. I think a lot of emphasis needs to be put on testing code. Like SQLite uses Tcl to script tests. C is easy to test because the “software units” are only structures and functions.
No kidding.
Re: Let's Destroy C
#100Earlier quoted context omitted.
Thanks, awesome paper (which remind me that I should read the ARM at some point). Interesting stuff: "Cfront [the fist c++ compiler] was (and is) a traditional compiler front− end performing a complete check of the syntax and semantics of the language" "[...] the C compiler is used as a code generator only. [...]. I stress this because there has been a long history of confusion about what Cfront was/is. It has been c…
I believe the "modern" term for Cfront would be "transpiler".
https://en.wikipedia.org/wiki/C--
> C-- (pronounced cee minus minus) is a C-like programming language. Its creators, functional programming researchers Simon Peyton Jones and Norman Ramsey, designed it to be generated mainly by compilers for very high-level languages rather than written by human programmers. Unlike many other intermediate languages, its representation is plain ASCII text, not bytecode or another binary format.[1][2]
> There are two main branches of C--. One is the original C-- branch, with the final version 2.0 released in May 2005.[3] The other is the Cmm fork actively used by the Glasgow Haskell Compiler as its intermediate representation.[4]