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

Invalid write in opj_j2k_update_image_data #495

Closed
gcode-importer opened this issue May 26, 2015 · 3 comments
Closed

Invalid write in opj_j2k_update_image_data #495

gcode-importer opened this issue May 26, 2015 · 3 comments

Comments

@gcode-importer
Copy link

Originally reported on Google Code with ID 495

So, there appears to be a regression of sorts in r2991 ("fixed a buffer overflow in
opj_tcd_init_decode_tile"). After that revision, the attached fuzzer-produced file
causes opj_j2k_update_image_data to write to invalid memory at line 8198:
   *(l_dest_ptr++) = (OPJ_INT32) ((*(l_src_ptr++))&0xff);

The problem is basically that l_img_comp_dest->w is a very large integer, large enough
that it causes l_line_offset_dest to become negative, and so "l_dest_ptr+= l_line_offset_dest"
decrements l_dest_ptr and causes it to point to an invalid address. You can reproduce
this by trying to decode the attached image with opj_decompress (tested on Linux x86-64).
The attached patch appears to catch this particular testcase, but because I don't fully
understand the underlying problem it's possible there are other ways of triggering
the issue or that this could break very large but valid images.

Reported by makosoft on 2015-05-26 20:13:34


- _Attachment: [openjpeg-svn-id000070svn-invalid-write-in-opj_j2k_update_image_data.isra.22.jp2](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-495/comment-0/openjpeg-svn-id000070svn-invalid-write-in-opj_j2k_update_image_data.isra.22.jp2)_ - _Attachment: [invalid-write-in-opj_j2k_update_image_data.patch](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-495/comment-0/invalid-write-in-opj_j2k_update_image_data.patch)_
@gcode-importer
Copy link
Author

Reported by mayeut on 2015-05-27 21:34:32

  • Status changed: Started
  • Labels added: Priority-Critical
  • Labels removed: Priority-Medium

@gcode-importer
Copy link
Author

This issue was updated by revision r3003.

Reported by mayeut on 2015-05-27 23:05:05

@gcode-importer
Copy link
Author

This issue was closed by revision r3004.

Reported by mayeut on 2015-05-27 23:05:25

  • Status changed: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants