4 ms·
The #define new has a , instead of multiplication. It will compile likely without warning, but cause buffer overflow. says “use sprintf”, which you shouldn’t d
by beagle3 7y ago
The #define new has a , instead of multiplication. It will compile likely without warning, but cause buffer overflow.
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.
- sherincall 7y agoThere 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().