Live data from Hacker News

Neverflow: C macros that guard against buffer overflows

github.com

11–20 of 150 posts

Re: Neverflow: C macros that guard against buffer overflows

#11
post #6
post #3

Earlier quoted context omitted.

Yeap, that's the whole point of it

Huh I misinterpreted the error messages in the example, I thought those were compiler output. This is quite cool then. EDIT: although, it seems like this looses much of its power once you start passing these buffers around to functions that do not use these macros.

[deleted]

Re: Neverflow: C macros that guard against buffer overflows

#13
post #9
post #5

Interesting idea, although given the demotion into optional feature in C11, it isn't necessarly portable. Also doesn't cover all the string and memory buffer manipulations. SAL and Frama-C are the bare minimum for security in C code.

Frama-C as a bare minimum is a pipe dream. It's a nice thought, don't get me wrong, but it's hard enough to convince people to add `-fsanitize=...` to their compiler flags. An entire separate static analysis tool with its own learning curve (and its own set of idiosyncrasies) doesn't really qualify for "bare minimum" IMO.

Thankfully the ongoing cybersecurity laws will change that mindset.

Re: Neverflow: C macros that guard against buffer overflows

#16
C23 improved struct compatibility so you might be able to leverage that to craft macros that better emulate slices. [1]

There is an RFC proposal for the Clang frontend for adding bounds checking reminiscent of Microsoft's SAL. [2]

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3003.pdf

[2] https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-...

Re: Neverflow: C macros that guard against buffer overflows

#17

Why use C and keep reinventing things that C++ provides?

If one is ready to switch languages, then the clear winner is rust over C++, and I say that as someone who avoided diving into Rust for years because it seemed completely overhyped and with too much cryptic syntax.

C still wins by far when writing libraries that will be used by lots of other people. Doesn't matter what language they are using, they will be able to add in a library written in C very easily. However, C++ or Rust libraries, even with appropriate bindings for the target language, users of the library will need to bring in an entirely new compiler tool chain that may or may not exist on the target architecture. But the C tool chain will exist for that architecture and be robust.

Re: Neverflow: C macros that guard against buffer overflows

#18
post #5

Interesting idea, although given the demotion into optional feature in C11, it isn't necessarly portable. Also doesn't cover all the string and memory buffer manipulations. SAL and Frama-C are the bare minimum for security in C code.

What is SAL?

Re: Neverflow: C macros that guard against buffer overflows

#19

Why use C and keep reinventing things that C++ provides?

the obvious answer is that one does not want some things that C++ entails, three examples: - name mangling - larger gap between source code and ISA - impedance mismatch when working with C APIs

that being said, some do not want more macros either

Re: Neverflow: C macros that guard against buffer overflows

#20
post #18
post #5

Interesting idea, although given the demotion into optional feature in C11, it isn't necessarly portable. Also doesn't cover all the string and memory buffer manipulations. SAL and Frama-C are the bare minimum for security in C code.

What is SAL?

Source-code annotation language (SAL) [1].

[1] https://learn.microsoft.com/en-us/cpp/code-quality/understan...

Post reply on HN