Skip to content

fix(rla): lots of additional validity checking and safety#5094

Open
lgritz wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
lgritz:lg-rlafix
Open

fix(rla): lots of additional validity checking and safety#5094
lgritz wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
lgritz:lg-rlafix

Conversation

@lgritz
Copy link
Collaborator

@lgritz lgritz commented Mar 18, 2026

  • Validity-check resolution of RLA files with check_open. RLA file headers contain int16_t values for left & right (and top/bottom) window coordinate, leading to a maximum resolution of 2^16-1.

  • Fix potential bug with sign extension in RLE decoding -- if a signed char is -128, negating it can't make signed char 128 (no such thing), so must widen the var to an int.

  • Fix potential bug by detecting when the number of matte or auxiliary bits is 0, but the number of matte or aux channels, respectively, is not.

  • Better bounds checking in decode_channel_group. We did the checks before, but after some accesses that would have been out of bounds! Move the checks earlier than all the accesses. It actually looks like was the result of a cut and paste error long ago.

  • More care in read_native_scanline for checking valid scanline numbers, offset into m_sot, and check whether ioseek succeeded (i.e. whether the offsets loaded from the file are within the range of the size of the file).

Code and fixes all are from my own brain, but some of the analysis of which spots have bounds issues were identified in part by conversation with Claude Code Opus 4.6.

* Validity-check resolution of RLA files with check_open.  RLA file
  headers contain int16_t values for left & right (and top/bottom)
  window coordinate, leading to a maximum resolution of 2^16-1.

* Fix potential bug with sign extension in RLE decoding -- if a signed
  char is -128, negating it can't make signed char 128 (no such
  thing), so must widen the var to an int.

* Fix potential bug by detecting when the number of matte or auxiliary
  bits is 0, but the number of matte or aux channels, respectively, is
  not.

* Better bounds checking in decode_channel_group. We did the checks
  before, but after some accesses that would have been out of bounds!
  Move the checks earlier than all the accesses. It actually looks like
  was the result of a cut and paste error long ago.

* More care in read_native_scanline for checking valid scanline
  numbers, offset into m_sot, and check whether ioseek succeeded
  (i.e. whether the offsets loaded from the file are within the range
  of the size of the file).

Code and fixes all are from my own brain, but some of the spots with
bounds issues were identified in part by conversation with Claude Code
Opus 4.6.

Assisted-by: Claude Code / Opus 4.6
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant