Question: The C standard library is notoriously poor when it comes to I/O safety. Many functions have buffer overflows (`gets`, `scanf`), or can clobber memory if not given proper arguments (`scanf`), and so on. Every once in a while, I come across an enterprising hacker who has written his own library that lacks these flaws.

What are the best of these libraries you have seen? Have you used them in production code, and if so, which held up as more than hobby projects?

Answer: 
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.
Maybe the first question to ask is if your really need plain C? (maybe a language like .net or java is an option - then e.g. buffer overflows are not really a problem anymore)

Another option is maybe to write parts of your project in C++ if other higher level languages are not an option. You can then have a C interface which encapsulates the C++ code if you really need C.

Because if you add all the advanced functions the C++ standard library has build in - your C code would only be marginally faster most times (and contain a lot more bugs than an existing and tested framework).