If rle block(s) contain(s) pixel count higher then these, specified in the header, the TGA loading will write beyond the end of the allocated dib.
The following patch adds a test for every packet to see if the dib has enough room. If it has not, an error is reported and the partially loaded image returned.
(One might return a null image instead, but I thought its nice to be able save what is left from the image)
Also the patch contains additional commenting and some minor renaming (for instance rle_count variable is renamed to packet_count which is a bit more clear)
Anonymous
Hi,
thanks for the patch, it is now merged with the CVS.
Hervé
The patch is broken.
It reports a false positive on the attached image.
Also the test does not respect the flip vert/horz flags.
I am investigating if the two are related.
(Vert/Horz flip is broken in the patch to begin with, so we will need some heavy refactoring to first fix it and than make the write-beyond-the-end test respect it )
Fails with the current patch
Yes, not respecting the horz/vert flips is the cause of failure .
...and quite messy if we do respect them...
And considering the horz/vert flip is broken, I doubt its worth it ...
May be its time to write the horz/vert flip code the right way...
Am interesting for the reason why FI behaves the way it does regarding these flip flags... Is it a bug or some workaround or something? Will "making it right" "break" the behavior?
Im asking for some insights.
Refactored and fixed
I have uploaded a heavily refactored patch, removing massive amount of code duplications and streamlining the handling of flip flags.
Hi,
Thanks, your patch is merged with the CVS. I've fixed loadTrueColor with the loading of some 32-bit dib, simplified the Validate function and also fixed minor signed/unsigned warnings.
Hervé
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).