Safer Alternatives to the C Standard Library Safer Alternatives to the C Standard Library c c

Safer Alternatives to the C Standard Library


I use GLib library, it has many good standard and non standard functions.

See https://developer.gnome.org/glib/stable/

and maybe you fall in love... :)

For example:

https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup-printf

explains that g_strdup_printf is:

Similar to the standard C sprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result.


This isn't really answering your question about the safest libraries to use, but most functions that are vulnerable to buffer overflows that you mentioned have safer versions which take the buffer length as an argument to prevent the security holes that are opened up when the standard methods are used.

Unless you have relaxed the level of warnings, you will usually get compiler warnings when you use the deprecated methods, suggesting you use the safer methods instead.


I believe the Apache Portable Runtime (apr) library is safer than the standard C library. I use it, well, as part of an apache module, but also for independent processes.