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

DPX output: fix write errors #3672

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Nov 15, 2022

There was a subtle error where we has a reference to an ImageSpec for one of the subimages, confusingly called m_spec, which we altered, but then didn't make the same change to the this->m_spec, and in a later spot we referenced the m_spec meaning the one in this. This could lead to a crash.

Fix, but not only that, rename to avoid the confusion. spec0 is the alias we us for the spec for subimage 0, and spec_s is the alias we use when referencing subimage N, and we really never use m_spec anymore to avoi any confusion. This should make it easier to reason about this code in the future and avoid thise kinds of mistakes.

A second error resulted from the situation where a failure in open() would return before one or both of m_buf or m_tilebuf were allocated. If the return status of open() were ignored and the caller subsequently attempted calls to write_scanline or write_tile, invalid memory could be accessed. Fix this with a variety of guards not only based on the allocation status of these buffers, but also issuing errors (and exiting early) from write_scanline or write_tile if they are called on an ImageInput that is not in fact open.

(Addresses 1651, 1652)

There was a subtle error where we has a reference to an ImageSpec for
one of the subimages, confusingly called m_spec, which we altered, but
then didn't make the same change to the this->m_spec, and in a later
spot we referenced the `m_spec` meaning the one in this. This could
lead to a crash.

Fix, but not only that, rename to avoid the confusion. `spec0` is the
alias we us for the spec for subimage 0, and `spec_s` is the alias we
use when referencing subimage N, and we really never use m_spec
anymore to avoi any confusion. This should make it easier to reason
about this code in the future and avoid thise kinds of mistakes.

A second error resulted from the situation where a failure in open()
would return before one or both of m_buf or m_tilebuf were allocated.
If the return status of open() were ignored and the caller
subsequently attempted calls to write_scanline or write_tile, invalid
memory could be accessed. Fix this with a variety of guards not only
based on the allocation status of these buffers, but also issuing
errors (and exiting early) from write_scanline or write_tile if they
are called on an ImageInput that is not in fact open.

(Addresses 1651, 1652)
@lgritz lgritz merged commit 32946e5 into AcademySoftwareFoundation:master Nov 16, 2022
@lgritz lgritz deleted the lg-dpxout branch November 16, 2022 20:05
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Nov 20, 2022
There was a subtle error where we had a reference to an ImageSpec for
one of the subimages, confusingly called m_spec, which we altered, but
then didn't make the same change to the this->m_spec, and in a later
spot we referenced the `m_spec` meaning the one in `this`. This could
lead to a crash.

Fix, but not only that, also rename to avoid the confusion. `spec0` is the
alias we us for the spec for subimage 0, and `spec_s` is the alias we
use when referencing subimage S, and we really never use m_spec
anymore to avoid any confusion. This should make it easier to reason
about this code in the future and avoid these kinds of mistakes.

A second error resulted from the situation where a failure in open()
would return before one or both of m_buf or m_tilebuf were allocated.
If the return status of open() were ignored and the caller
subsequently attempted calls to write_scanline or write_tile, invalid
memory could be accessed. Fix this with a variety of guards not only
based on the allocation status of these buffers, but also issuing
errors (and exiting early) from write_scanline or write_tile if they
are called on an ImageInput that is not in fact open.

Addresses TALOS-2022-1651 / CVE-2022-43592 and 
TALOS-2022-1652 / CVE-2022-43593
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