-
Notifications
You must be signed in to change notification settings - Fork 256
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
[BUG] constant 0xFFFFFFFFFF overflows int in jbig2 #144
Comments
I think PR148 should solve. But how can I test it ? it seems that the update is not in the development branch. So I don't know how/where to get it. |
PR148 solves the problem. I am to build on default Windows configuration, do the cross compilation. |
Just to complete my comments: i didn't do specific test on the images by themselves. I can't confirm that the global behavior remains unchanged |
Fixed by #148 |
Description
During ARM (for Raspberry Pi) compilation there is message about int overflow. Cannot build the code on 32bit architecture.
This is related to the use of constant 0xFFFFFFFF... in the jbig2 code and the management of the constants by golang.
Expected Behavior
Code should be robust / portable to 32bits application.
If some part of the code is not 32bits compliant, the functions have to be deactivated or modified for 32bits.
Note 1: In several places, I replace the 0xFFF... constant by math.MaxInt32. Project is building but I didn't run the Unipdf tests. The use of -1 constant value seems more appropriate as it will be independent of the 32bits / 64 bits architecture.
Note 2:
In \github.com\unidoc\unipdf\v3\internal\jbig2\segments\page-information.go, the definition of type PageInformationSegment provides:
// Page bitmap height, four byte, 7.4.8.1
PageBMHeight int
// Page bitmap width, four byte, 7.4.8.1
PageBMWidth int
// Page X resolution, four byte 7.4.8.3
ResolutionX int
// Page Y resolution, four byte 7.4.8.4
ResolutionY int
-->As the 4 bytes shall be respected, it seems more appropriate to use a int32 (or uint32 as height, width,... remain positive?) instead of a int (except if it is explicitly required by the jpeg specification)
Actual Behavior
I build cross compilation on Win 10 for my personal project with the following parameters:
GOARCH=arm
GOOS=linux
GOARM=5
Attachments
Messages issued during compilation:
\github.com\unidoc\unipdf\v3\internal\jbig2\decoder\arithmetic\arithmetic.go:234:2: constant 9223372036854775807 overflows int
..\github.com\unidoc\unipdf\v3\internal\jbig2\segments\halftone-segment.go:341:27: constant 4294967295 overflows int
..\github.com\unidoc\unipdf\v3\internal\jbig2\segments\halftone-segment.go:347:28: constant 4294967295 overflows int
..\github.com\unidoc\unipdf\v3\internal\jbig2\segments\page-information.go:89:20: constant 1099511627775 overflows int
..\github.com\unidoc\unipdf\v3\internal\jbig2\page.go:306:22: constant 4294967295 overflows int
The text was updated successfully, but these errors were encountered: