Menu ▾ ▴

#37 [TGA]Corrupt rle count fix

closed
None
5
2012-10-31
2010-02-25
No

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)

Discussion

  • Hervé Drolon

    Hervé Drolon - 2010-02-25

    Hi,
    thanks for the patch, it is now merged with the CVS.
    Hervé

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-03-11

    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 )

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-03-11

    Fails with the current patch

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-03-11

    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.

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-03-12

    Refactored and fixed

     
  • Mihail Naydenov

    Mihail Naydenov - 2010-03-12

    I have uploaded a heavily refactored patch, removing massive amount of code duplications and streamlining the handling of flip flags.

     
  • Hervé Drolon

    Hervé Drolon - 2010-03-14

    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é

     
  • SourceForge Robot

    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).

     

Anonymous
Anonymous

Add attachments
Cancel