4 ms·
We need to delete 'sprintf' forever.
by mleonhard 6y ago
We need to delete 'sprintf' forever.
- josefx 6y agoDeleting sprintf by itself wouldn't work, even the "safe" replacement functions rely on the developer providing the safety information manually. C needs a string type. Sadly large parts of the C standard are build around turning plain character arrays into exploits by pretending that they are a sane choice for string manipulation.
- cozzyd 6y agoasprintf is fine for most cases. For the other cases you probably don't want to dynamically allocate memory so snprintf with a fixed buffer size is fine.
- benibela 6y agoThat is why I use Pascal and never had a safety problem when processing strings. It is completely baffling that people still use C in production Only issue is that the default string type requires heap allocations