<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - moshe</title>
<link>http://snipplr.com/users/moshe</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Sun, 19 May 2013 00:00:37 GMT</pubDate>
<item>
<title>(C++) Performing sprintf without overflowing the buffer</title>
<link>http://snipplr.com/view/64968/performing-sprintf-without-overflowing-the-buffer/</link>
<description><![CDATA[ <p>The problem is that we don't know the size of the required output buffer.  Providing a static buffer, no matter its size, runs a risk of overrunning the buffer.

This snippet uses vsnprintf() to output an sprintf() string based on a variable length parameter list to a dynamically allocated output buffer.  The function is provided with the size of the output buffer, and it returns -1 if the buffer is not large enough.  In this case, the code reallocates a larger buffer and attempts once again to output the string.  The vsnprintf() will succeed when the buffer is large enough.</p> ]]></description>
<pubDate>Mon, 21 May 2012 18:29:52 GMT</pubDate>
<guid>http://snipplr.com/view/64968/performing-sprintf-without-overflowing-the-buffer/</guid>
</item>
</channel>
</rss>