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

Issue 13589: tesseract-ocr/fuzzer-api: Undefined-shift in IntegerMatcher::UpdateTablesForFeature #2297

Closed
stweil opened this issue Mar 8, 2019 · 3 comments
Milestone

Comments

@stweil
Copy link
Contributor

stweil commented Mar 8, 2019

Issue reported by OSS Fuzz:

intmatcher.cpp:824:59: runtime error: left shift of negative value -18
 #0 0x609e27 in IntegerMatcher::UpdateTablesForFeature(INT_CLASS_STRUCT*, unsigned int*, unsigned int*, int, INT_FEATURE_STRUCT const*, ScratchEvidence*, int) tesseract/src/classify/intmatcher.cpp:824:59

The same issue is also reported when code is built with GCC sanitizers (for example when running the stringrenderer_test), see Wiki for build instructions.

@stweil stweil changed the title Undefined-shift · IntegerMatcher::UpdateTablesForFeature Issue 13589: tesseract-ocr/fuzzer-api: Undefined-shift in IntegerMatcher::UpdateTablesForFeature Mar 8, 2019
stweil added a commit to stweil/tesseract that referenced this issue Mar 11, 2019
Shift operations are undefined for negative numbers, but at least on
Intel they return the same value as a multiplication with 2 ^ shift value.

This fixes runtime errors reported by sanitizers and OSS-Fuzz:

    intmatcher.cpp:821:59: runtime error: left shift of negative value -14
    intmatcher.cpp:823:75: runtime error: left shift of negative value -512
    intmatcher.cpp:820:50: runtime error: left shift of negative value -80

See issue tesseract-ocr#2297 and
https://oss-fuzz.com/testcase-detail/4845195990925312 for details.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
@stweil
Copy link
Contributor Author

stweil commented Mar 11, 2019

This issue is addressed in pull request #2309.

@stweil stweil added this to the 4.1.0 milestone Mar 11, 2019
stweil added a commit to stweil/tesseract that referenced this issue Mar 12, 2019
Shift operations are undefined for negative numbers, but at least on
Intel they return the same value as a multiplication with 2 ^ shift value.

This fixes runtime errors reported by sanitizers and OSS-Fuzz:

    intmatcher.cpp:821:59: runtime error: left shift of negative value -14
    intmatcher.cpp:823:75: runtime error: left shift of negative value -512
    intmatcher.cpp:820:50: runtime error: left shift of negative value -80

See issue tesseract-ocr#2297 and
https://oss-fuzz.com/testcase-detail/4845195990925312 for details.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
@zdenop
Copy link
Contributor

zdenop commented Apr 26, 2019

Is this fixed?

@stweil
Copy link
Contributor Author

stweil commented Apr 26, 2019

This issue is fixed, see https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13589.

@stweil stweil closed this as completed Apr 26, 2019
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

No branches or pull requests

2 participants