dekadenZ/Dagon — pull request #1 by dekadenZ (2013-04-11 05:54:28+00:00)
Title: Fix potential buffer overflow

* vsprintf() can overflow the output buffer; use vsnprintf() instead.
* unnecessary calls to strlen()
- on every iteration just to see if the string end has been reached yet,
- even though the upper bound can be derived from the return value of vsnprintf().

Unfortunately Microsoft's CRT returns a non-standard value, if vsnprintf() wants to write more than 'size' chars, so I handled that case differently in a wrapper around vsnprintf().