5 ms·
I didn't even know that scnprintf was a thing. Cool! I learned something just by skimming the video
by greesil 8y ago
I didn't even know that scnprintf was a thing. Cool! I learned something just by skimming the video
- ddtaylor 8y agoI think the presenter mentions it's only in Linux kernel though, not available in userspace.
- chacham15 8y agoThe userspace version is snprintf.
- aboutruby 8y agoThe speaker mentions it, seems like the return value is different: https://i.imgur.com/Jj2fMZu.png https://i.imgur.com/Jj2fMZu.png
- Taniwha 8y agoyes - snprintf() returns the length of the string that would be written even if it wasn't clipped to the length of the output buffer - if you want to accumulate strings into a buffer using the output length to update the offset/size bad things will happen. scnprintf() returns the actual number of bytes written (less the null)
- technion 8y agoThere's a great write up here on how assuming scnprintf behaved like snprintf led to memory bugs: http://blog.infosectcbr.com.au/2018/11/memory-bugs-in-multiple-linux-kernel.html http://blog.infosectcbr.com.au/2018/11/memory-bugs-in-multip...
- kzrdude 8y agoThe C standard's snprintf is not like scnprintf.