Menu

#7039 Indeo3 unaligned accesses

*None
closed-fixed
None
5
2016-02-20
2016-02-14
No

The indeo3 codec reads from the unaligned pointer 'ref_frm_pos' without using the appropriate memory access macros (READ_UINT16, READ_UINT32).

This causes crashes at least for BBVS on MIPS. Reported and tracked down by joostp.

Discussion

  • Willem Jan Palenstijn

    NB: There are also derived pointers such as 'ref_lp' that need attention.

     
  • Joost Peters

    Joost Peters - 2016-02-17

    Attached is a patch that enables alignment checking in Indeo3Decoder::decodeChunk() on x86/x86_64, so that the issue can be reproduced more easily.

    After applying the patch, make sure to compile ScummVM with SCUMM_NEED_ALIGNMENT defined:

    CXXFLAGS="-DSCUMM_NEED_ALIGNMENT" ./configure ...

     

    Last edit: Joost Peters 2016-02-17
  • Willem Jan Palenstijn

    I don't think that patch will work, since it won't force the compiler to generate unaligned read instructions.

    I have an attempt at a fix at https://github.com/wjp/scummvm/commits/indeo3_align .
    Could you test if it works for you?

     
  • Willem Jan Palenstijn

    If I disable optimizations, and force common/endian.h to fall back to the block of single-byte reads, I can use this patch to test it on x86 it seems, and with my patch to indeo3 it then no longer crashes.

     
  • Joost Peters

    Joost Peters - 2016-02-17

    Your patch fixes the crashes for me as well, nice. :)

     
  • Johannes Schickel

    Sounds good. Did we convince ourselves that the writes really are no issue and are always aligned?

     
  • Joost Peters

    Joost Peters - 2016-02-18

    I didn't check extensively, but the pointers that were written to that I looked at seemed to be aligned (don't know if that was due to luck or 'design', though).

     
  • Willem Jan Palenstijn

    • status: open --> closed-fixed
    • assigned_to: Willem Jan Palenstijn