<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: String Theory (..for Windows)</title>
	<link>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/</link>
	<description>Continued ramblings on software security and code auditing</description>
	<pubDate>Fri, 30 Jul 2010 13:23:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>

	<item>
		<title>by: Robin Keir</title>
		<link>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-341</link>
		<pubDate>Thu, 22 Mar 2007 21:01:00 +0000</pubDate>
		<guid>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-341</guid>
					<description>One little gotcha with lstrcpyn(A/W) is that if the last parameter, the number of characters asked to be copied, is zero then nothing at all is done  no characters are written, leaving youre destination buffer untouched.

Imagine this:

 char szBuffer1[32];

 char szBuffer2[] = Hello world;

 int nCharsToCopy = [some user supplied validated as &#62;= 0];

 lstrcpyn(szBuffer1, szBuffer2, nCharsToCopy);

szBuffer1 is left completely uninitialized, potentially unterminated.</description>
		<content:encoded><![CDATA[<p>One little gotcha with lstrcpyn(A/W) is that if the last parameter, the number of characters asked to be copied, is zero then nothing at all is done  no characters are written, leaving youre destination buffer untouched.</p>
<p>Imagine this:</p>
<p> char szBuffer1[32];</p>
<p> char szBuffer2[] = Hello world;</p>
<p> int nCharsToCopy = [some user supplied validated as &gt;= 0];</p>
<p> lstrcpyn(szBuffer1, szBuffer2, nCharsToCopy);</p>
<p>szBuffer1 is left completely uninitialized, potentially unterminated.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: mark</title>
		<link>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-72</link>
		<pubDate>Fri, 12 Jan 2007 01:47:39 +0000</pubDate>
		<guid>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-72</guid>
					<description>ron: Thanks! Yeah, the scanf() family of functions might have been a good addition. I did consider it - essentially, there is a huge amount of string functions in addition to the ones i posted - *gets(), *scanf(), and many, many more if you look over MSDN. I just felt I should draw the line somewhere, because the post was getting quite large. Scanf() functions are a borderline case though, they are used with relative frequency, I suppose.

anonymous: I know it, baby!</description>
		<content:encoded><![CDATA[<p>ron: Thanks! Yeah, the scanf() family of functions might have been a good addition. I did consider it - essentially, there is a huge amount of string functions in addition to the ones i posted - *gets(), *scanf(), and many, many more if you look over MSDN. I just felt I should draw the line somewhere, because the post was getting quite large. Scanf() functions are a borderline case though, they are used with relative frequency, I suppose.</p>
<p>anonymous: I know it, baby!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: ron</title>
		<link>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-69</link>
		<pubDate>Thu, 11 Jan 2007 16:31:50 +0000</pubDate>
		<guid>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-69</guid>
					<description>Good post, im surprised you didnt include the often misused sscanf() family.</description>
		<content:encoded><![CDATA[<p>Good post, im surprised you didnt include the often misused sscanf() family.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: jm</title>
		<link>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-66</link>
		<pubDate>Tue, 09 Jan 2007 15:01:05 +0000</pubDate>
		<guid>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-66</guid>
					<description>Good point, but I should explain that our primary concern is with auditing real-world code. So, even if there are safer ways of doing things, we have to focus on what people actually do in practice.</description>
		<content:encoded><![CDATA[<p>Good point, but I should explain that our primary concern is with auditing real-world code. So, even if there are safer ways of doing things, we have to focus on what people actually do in practice.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: DrPizza</title>
		<link>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-65</link>
		<pubDate>Tue, 09 Jan 2007 13:56:08 +0000</pubDate>
		<guid>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-65</guid>
					<description>I say this only because this post was tagged "C/C++", and because you mention functions that are supplied with VC++, but there is, of course, C++'s string library, which has two convenient properties:
1) it's counted (no annoying null termination to mess with)
2) it takes care of ensuring that the buffer is the right size for you

I would argue that using the functions described in this post is unnecessarily complicated and that std::string/std::wstring are the only sensible string libraries that people should use.  C strings are just asking for trouble.  The only reasonable objection I think is the lack of a printf() equivalent, although this is not insurmountable (due to stringstreams and various parts of the Boost library).</description>
		<content:encoded><![CDATA[<p>I say this only because this post was tagged &#8220;C/C++&#8221;, and because you mention functions that are supplied with VC++, but there is, of course, C++&#8217;s string library, which has two convenient properties:<br />
1) it&#8217;s counted (no annoying null termination to mess with)<br />
2) it takes care of ensuring that the buffer is the right size for you</p>
<p>I would argue that using the functions described in this post is unnecessarily complicated and that std::string/std::wstring are the only sensible string libraries that people should use.  C strings are just asking for trouble.  The only reasonable objection I think is the lack of a printf() equivalent, although this is not insurmountable (due to stringstreams and various parts of the Boost library).
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: kumara</title>
		<link>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-64</link>
		<pubDate>Tue, 09 Jan 2007 06:55:28 +0000</pubDate>
		<guid>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-64</guid>
					<description>thats really cool man thnx</description>
		<content:encoded><![CDATA[<p>thats really cool man thnx
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: anonymous</title>
		<link>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-63</link>
		<pubDate>Tue, 09 Jan 2007 05:49:38 +0000</pubDate>
		<guid>http://taossa.com/index.php/2007/01/09/string-theory-for-windows/#comment-63</guid>
					<description>mark is so sexy!</description>
		<content:encoded><![CDATA[<p>mark is so sexy!
</p>
]]></content:encoded>
				</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.083 seconds -->
