Skip to content

Fix undefined behavior in line drawing.#21512

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
vrabaud:3.4_ub_drawing
Jan 25, 2022
Merged

Fix undefined behavior in line drawing.#21512
opencv-pushbot merged 1 commit intoopencv:3.4from
vrabaud:3.4_ub_drawing

Conversation

@vrabaud
Copy link
Copy Markdown
Contributor

@vrabaud vrabaud commented Jan 25, 2022

Left shift of negative values is undefined but works in practice.
A test is useless as there is no MSAN on the build farm.

This is a follow-up on https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40230

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch

Left shift of negative values is undefined.
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@opencv-pushbot opencv-pushbot merged commit e3a4ff3 into opencv:3.4 Jan 25, 2022
@vrabaud vrabaud deleted the 3.4_ub_drawing branch January 25, 2022 16:20
@alalek alalek mentioned this pull request Jan 28, 2022
vrabaud added a commit to vrabaud/opencv that referenced this pull request Feb 9, 2022
Left shift of negative values is undefined but works in practice.
A test is useless as there is no UBSAN on the build farm.

This is a follow-up on https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44270
and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44386

The pull request opencv#21512 was incomplete.
vrabaud added a commit to vrabaud/opencv that referenced this pull request Feb 9, 2022
Left shift of negative values is undefined but works in practice.
A test is useless as there is no UBSAN on the build farm.

This is a follow-up on https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44270
and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44386

The pull request opencv#21512 was incomplete.
vrabaud added a commit to vrabaud/opencv that referenced this pull request Feb 9, 2022
https://godbolt.org/z/zhcj4h1xz
Left shift of negative values is implementation defined. We make sure that we always shift a positive.
A test is useless as there is no UBSAN on the build farm.

This is a follow-up on https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44270
and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44386

The pull request opencv#21512 was incomplete.
vrabaud added a commit to vrabaud/opencv that referenced this pull request Feb 9, 2022
https://godbolt.org/z/zhcj4h1xz
Left shift of negative values is implementation defined. We make sure that we always shift a positive.
A test is useless as there is no UBSAN on the build farm.

This is a follow-up on https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44270
and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44386

The pull request opencv#21512 was incomplete.
@alalek alalek mentioned this pull request Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants