Giter VIP home page Giter VIP logo

Comments (5)

aous72 avatar aous72 commented on May 24, 2024

Hi Aaron,

Thank you for putting this in. Yes, it can happen.

The cleanup pass of a HTJ2K codeblock is made up of three sections; in order, they are: the magnitude-sign (MagSgn) section, which is read from the first byte going forward; the MEL section, which is also read forward; and the VLC section, which is read from the last byte going backward.

For convenience, here we read 4 bytes at a time from the VLC section. So if the MagSgn and MEL are short (the MEL section can have 0 bytes), there is the possibility that when we reading from the VLC section, we read from before the first byte of the MagSgn section (i.e., from before the first byte in the codeblock).

This needs to be fixed. Let's keep this issue open until I fix it.

Thank you again.

Kind regards,
Aous.

from openjph.

boxerab avatar boxerab commented on May 24, 2024

Great, thanks for the explanation, and for looking into this.

from openjph.

aous72 avatar aous72 commented on May 24, 2024

Hi Aaron,

I should have come earlier, but my head is in another project.

I added 8 bytes in front of the buffer. If vlcp->size becomes smaller than -8, an error message will terminate the code. There is an additional 24 bytes of memory before the vlcp->buf field, which are used to store information about the buffer size and the likes; have a look at 'struct coded_lists' in ojph_mem.h if you like.

I could not replicate the issue with valgrind (this is the first time I use it), but since I knew about the possibility, I added the extra space, in addition to the existing 24 bytes. In any case, the code should not read from these 24 bytes.

It can useful to replicate the issue you faced. The bug might be somewhere else. I need more details, so if you have the time, please provide more details. You linked the original ppm file, but I am not very sure what options were used with it. I am also not very sure what options were given to valgrind.

While fiddling with valgrind, I discovered a bug in the encoder, which I totally overlooked in the past. I think I need to add valgrind to the necessary tools in my repertoire.

Thank you for all your help.

Kind regards,
Aous.

from openjph.

boxerab avatar boxerab commented on May 24, 2024

Hi Aous,
Thanks a lot for these fixes. Yes, valgrind is a fantastic tool to have in your toolkit.
I will do some more testing, and share the settings I used.
Best,
Aaron

from openjph.

boxerab avatar boxerab commented on May 24, 2024

I haven't found any valgrind errors in a while. Closing.

from openjph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.