On 4/7/06, <b class="gmail_sendername">James Hawkins</b> &lt;<a href="mailto:truiken@gmail.com">truiken@gmail.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 4/7/06, Tom Spear (Dustin Booker, Dustin Navea) &lt;<a href="mailto:speeddymon@gmail.com">speeddymon@gmail.com</a>&gt; wrote:<br>&gt; &gt;<br>&gt; &gt; if (srclen &lt; 0) srclen = strlenW(src) + 1;<br>&gt; &gt;<br>&gt; &gt; so we never access the string with a negative index.
<br>&gt; &gt;<br>&gt;<br>&gt; Umm, all that does is increment it by 1...&nbsp;&nbsp;What if _somehow_ (dont ask<br>&gt; me how, just venturing a guess) a bogus number is passed by strlenW(src)<br>&gt; like -3789246?&nbsp;&nbsp;Then you end up with srclen == -3789245...
<br>&gt;<br><br>strlen returns a value of type size_t, which is an unsigned value, so<br>this is always going to be positive.<br><br>&gt; &gt; * Negative value can be returned and we don't check for it.<br>&gt; &gt;<br>&gt; I could be wrong, but wouldnt it be (theoretically speaking) possible
<br>&gt; for a program to force a negative number out of it (even though it isnt<br>&gt; supposed to be able to), since it IS an int, regardless of the return<br>&gt; value type?<br>&gt;<br><br>If I write a function foo(x,y) that returns a signed int, but I only
<br>ever return a value &gt;= 0, then no matter what input the user gives for<br>x and y, a negative value can never be returned.&nbsp;&nbsp;The problem is that<br>MS decided to make the return type of WideCharToMultiByte int instead
<br>of unsigned int, which we can't change.&nbsp;&nbsp;Let's say hypothetically that<br>a negative value can be returned in our implementation, then it's<br>still a bug in WideCharToMultiByte and these Coverity bugs are still<br>false positives.
<br><br></blockquote></div>That is true, but we also need to make sure that since we are going for conformity (including conforming to MS's bugs) we don't fix a bug in our code that is reported by Coverity, but that is also a bug in MS code..&nbsp; So if a game has to work around a bug in MS code, then our code should still have that bug (so the game will work correctly), even if Coverity picks it up....
<br><br>Tom<br>