-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
hidparser.c: GetValue() can return incorrect result when compiled for 64-bit environment #1023
Comments
In GetValue --
If you're in an ILP32 environment, range (long) will be < 0 if there was overflow in the calculation, which there is in this case of Min=-1, Max=2147483647, and so it will never do any checking and just return the value. |
I've got a revised implementation for |
Sorry for the delay. Unfortunately, currently there are not many tests present, and those that are - are mostly for code quality/syntax. There was a long-standing plan to mock some device activities (so dummy-ups appeared) to test the upsd server and its clients, but probably nothing in place for testing against real hardware - including workarounds for known-broken hardware (and the chain of OS drivers, libs, etc. leading to that) especially as there is no persistent pool of HW for the project... just some team members or users and contributors reporting results with what they have on hand. |
While working on #616 I noticed the following issue caused by this change.
And after the changes made here, I see wrong values of -0.1, -1 respectively
|
Thanks for the report about possible regression, I've posted a PR to help investigate this. THX: #1138 |
I've discovered, with the attached test case (rename the .txt to .c), using
testgetvalue.txt, code copied from hidparser.c, that extracting a value from a report:
with
GetValue(&Buf, &Data, &Value)
, independent of whether the processor is big-endian or little-endian, produces Value = -1 when compiled in an ILP32 environment and Value = 0 when compiled in an LP64 environment.I'll track down the problem and propose a fix.
The text was updated successfully, but these errors were encountered: