Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ld-lds-converter potential read/write beyond array bounds #477

Closed
coderjo opened this issue Apr 4, 2020 · 1 comment
Closed

ld-lds-converter potential read/write beyond array bounds #477

coderjo opened this issue Apr 4, 2020 · 1 comment
Labels
bug ld-decode-tools An issue only affecting the ld-decode-tools

Comments

@coderjo
Copy link

coderjo commented Apr 4, 2020

When converting a 16-bit file to a packed 10-bit file, if the input file is not an exact multiple of 8 bytes, the last iteration reads past the end of inputBuffer. Since outputBuffer::operator[] is used to assign to the output, it will properly resize as needed.

When unpacking a 10-bit file to a 16-bit file, if the input file is not an exact multiple of 5 bytes, inputBuffer is resized (but will have whatever garbage was already there), but the assignment into output will write past the end of the outputBuffer.

I can see two possible solutions:

  1. error on an offending input stream
  2. pad the input with 0s as needed to fill the last iteration
@simoninns simoninns added bug ld-decode-tools An issue only affecting the ld-decode-tools labels Apr 4, 2020
simoninns pushed a commit that referenced this issue Jul 30, 2020
simoninns pushed a commit that referenced this issue Jul 30, 2020
@simoninns
Copy link
Collaborator

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ld-decode-tools An issue only affecting the ld-decode-tools
Projects
None yet
Development

No branches or pull requests

2 participants