[Cryptography] bounded pointers in C

Viktor Dukhovni cryptography at dukhovni.org
Fri Apr 18 14:44:34 EDT 2014


On Fri, Apr 18, 2014 at 02:10:52PM -0400, Jerry Leichter wrote:

> > A major step forward would be to simply extend the standard library
> > with a suitably safe set of new interfaces.  Basically safe strings
> > and a safe stdio library that works with these.  We don't have to
> > make incompatible changes to the language.
>
> See my (2002) article at http://catless.ncl.ac.uk/Risks/21.85.html#subj5.4

I agree 100% with the key observation: "culture matters".  Most of
what's wrong with software in C is cultural.

In Postfix, Wietse has created a project-specific style (sub-culture)
of C programming, which has been used consistently as the project
evolved, over the past 17 years.  This sub-culture emphasizes
safety, comprehensive documentation, and code written for readability.

The architecture assumes that bugs are inevitable (though in fact
due to the above substantially less frequent than in other projects
of a similar size) and aims to minimize their impact through
privilege separation.

In OpenSSL, there a different style of C programming prevails,
which has also been consistent on a similar time-scale.  This style
does not emphasize safety, allows undocumented features and the
code is noticeably more cryptic (no pun intended).

So while much of the "blame" can be apportioned to lack of suitable
out of the box safe interfaces in the C standard library, the rest
is the result of choices made by the project to deliver on features
despite inadequate resources to invest in internal interfaces and
programming styles that could have made errors much less likely
and typically less severe.

-- 
	Viktor.


More information about the cryptography mailing list