Re:Some simple tricks in C/C++
by sherincall on Wednesday May 06, 2020 @11:58AM
(#23092521)
There are several instances of bad syntax in the article. Easy to make mistakes if you don't write C daily. I assume they meant to use calloc() here instead of malloc().
says “use sprintf”, which you shouldn’t do because ... buffer overflow (it’s possible to avoid but you need to really know what you are doing and set a maximum length for any conversion, which article authors does not do). For the same use cases, Proper use of snprintf would avoid overflows.
Other advice seems ok to me.