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

fix(raw): Avoid buffer overrun for flip direction cases #4100

Merged
merged 2 commits into from
Jan 8, 2024

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Dec 31, 2023

If you are looping i over range [0,width), and want index to go the other direction, you need index = width - 1 - i, not index = width - i.

Identified by Sonar static analysis.

If you are looping i over range [0,width), and want index to go the
other direction, you need `index = width - 1 - i`, not
`index = width - i`.

Identified by Sonar static analysis.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@@ -1505,7 +1505,7 @@ RawInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
// to the array direction so we must copy the pixels into a temporary contiguous buffer
else if (sizes.flip == 5 /*90 degrees CCW*/
|| sizes.flip == 6 /*90 degrees CW*/) {
scanline_start = m_spec.height - y + sizes.left_margin;
scanline_start = m_spec.height - 1 - y + sizes.left_margin;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the scanline_start expression on Line 1496 also need the -1 adjustment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you are correct, I will fix there as well

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
Copy link
Collaborator Author

lgritz commented Jan 5, 2024

@Shootfast I would love your opinion on this.

@Shootfast
Copy link
Contributor

LGTM!

@lgritz lgritz merged commit 2a44392 into AcademySoftwareFoundation:master Jan 8, 2024
25 checks passed
@lgritz lgritz deleted the lg-raw branch January 13, 2024 07:23
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Jan 21, 2024
…areFoundation#4100)

If you are looping i over range [0,width), and want index to go the
other direction, you need `index = width - 1 - i`, not `index = width - i`.

Identified by Sonar static analysis.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
1div0 pushed a commit to 1div0/OpenImageIO that referenced this pull request Feb 24, 2024
…areFoundation#4100)

If you are looping i over range [0,width), and want index to go the
other direction, you need `index = width - 1 - i`, not `index = width - i`.

Identified by Sonar static analysis.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
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.

None yet

3 participants