Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DPX output: fix write errors (#3672)
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
- Loading branch information