Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've spent a lot of time reading C sources. Standouts are nginx, mbed TLS, Amazon s2n. Clean coding styles, consistent in checking function return values (very important! significant source of vulnerabilities in C software), comments where due, no hacks.

Among the most convoluted source codes I've read is Tor. It works (apparently), and it isn't even very insecure per se (the code is littered with hard asserts that will abort code execution if an expected condition isn't met), but it is unnecessarily dense. Example: I use software to analyze the call graph (which function calls which function) and when I ask it to find potentially recursive loops (A() calls B() calls A() etc) it spews out tens of thousands of potential recursions.

By comparison, mbed TLS only has a couple of these, and a large project like OpenSSL 50 or so.

Conversely, C software that isn't consistent in error signaling (return -1 on error in function A, return 0 in function B, set parameter int* err in function C, etc), doesn't perform due error checking, whose call graph is spaghetti, mindlessly performs multiplication (leading to overflows with certain inputs), uses signed or unsigned int where size_t is better suited, are usually susceptible to bugs and abuse (vulnerabilities). The projects I mentioned are very clean in this regard.



Noted below, but I'd also highly recommend Redis for clean code.


What software do you use to analyze call graphs?


> it is unnecessarily dense

Underhanded perhaps?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: