<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 14, 2018 at 10:47 AM, Levente Uzonyi <span dir="ltr"><<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Eliot,<span class=""><br>
<br>
On Thu, 12 Apr 2018, Eliot Miranda wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[I'm sorry, I apparently forgot to hit send some weeks ago]<br>
</blockquote>
<br></span>
Well, I had started to rewrite the methods myself along with adding tests, but you were quicker and pushed the changes.<br>
I think there are still things that should be fixed. When time allows, I'll check my tests and merge them with the existing MiscPrimitivePluginTest.</blockquote><div><br></div><div>thanks, man!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
primitiveDecompressFromByteArr<wbr>ay<br>
- bm is int*, but it should probably be unsigned int* as the method <br>
</blockquote></blockquote>
stores unsigned ints (data) into it<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- index should be bounds checked (1 .. end)<br>
</blockquote>
<br>
It gets checked anyway with the comparison against pastEnd<br>
</blockquote>
<br></span>
Unfortunately that's not the case. i is compared to end, not pastEnd.<br>
If index, which is an unnecessary variable btw, is less than or equal to 0, then the value of i will be negative, and the input will be processed no matter what the value of end is, hence random data from memory will be read and processed:<br>
<br>
Smalltalk garbageCollect.<br>
ba := ByteArray new: 256.<br>
bm := Bitmap new: 1024.<br>
passes := OrderedCollection new.<br>
success := true.<br>
[<br>
        0 to: -1000000 by: -1 do: [ :start |<br>
                success := true.<br>
                bm decompress: bm fromByteArray: ba at: start.<br>
                success ifTrue: [ passes add: start ] ] ]<br>
        on: Error<br>
        do: [ :error |<br>
                success := false.<br>
                error return: nil ].<br>
passes<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- i, k, end and pastEnd should be unsigned int<br>
</blockquote>
<br>
That's OK.  In neither V3 nor Spur can objects have more than 1Gb fields so in practice indices can never go negative.<br>
</blockquote>
<br></span>
If i's type were unsigned int, the above code wouldn't work, because i < end would be false.<span class="HOEnZb"><font color="#888888"><br>
<br>
Levente<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>