4 ms·
This inspired me to grep the cpython code for sprintf. I found one used with the return value from alloca (inside FindAddress in _ctypes.c). It checks alloca f
by cozzyd 6y ago
This inspired me to grep the cpython code for sprintf.
I found one used with the return value from alloca (inside FindAddress in _ctypes.c). It checks alloca for NULL (does alloca ever return NULL?), but I could imagine it might expoitable. FindAddress is a static function that can be called during DLL loading. I imagine that there is very little code that accepts untrusted arguments to DLL loading though (if so, there are bigger problems...).
There is also a lot of use of fixed 32-byte buffers, for up-to-64 bit numbers, which is fine, but hopefully if in the future they can be 128-bit, people remember to fix it!
In other cases, like getnameinfo, the stack-allocated buffer is way too large! %d can never be 512 bytes, so it's just thrashing your cache for no reason.
Anyway surely this has been carefully audited, since grepping for sprintf is so simple!
- deleted 6y ago[deleted]
- macintux 6y ago> Anyway surely this has been carefully audited, since grepping for sprintf is so simple! That is rarely a safe assumption.