-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
std::math::accumulate
bug with size>1
#95
Comments
I just tested the pattern provided on an input of 16 0x01's on the master branch (1.33.0) and got these results:
so the bug that made output 5 and 6 zero seems to be fixed already. The proposed fix is not correct and there seems to be at least two problems in the current code. The variable called The other problem is that the address needs to be incremented by Based on that evidence I believe that the corrections should be: |
std::math::accumulate
bugs: "last file byte" and "non-zero start and >1 size"std::math::accumulate
bug: "non-zero start and >1 size"
@paxcut Great thanks! I didn't tried master since it had pattern editor GUI bugged for me Renamed this bug to only track "size > 1" case However regarding the theoretical fix - looking with a fresh eyes - it seems to be another way: |
std::math::accumulate
bug: "non-zero start and >1 size"std::math::accumulate
bug with size>1
Like I mentioned above, I am not sure which of two cases this function is supposed to return so I got myself confused and mixed both cases together. One case is when the loop overlaps numbers in which case a loop step of one is needed, but that seems to me to be of little use so I'm guessing that the loop step of |
Using imhex version is 1.33.2 I tried to use std::math::accumulate to verify the entire file u8 sum equals the value required b a format I'm investigating. However I found a bug thatseems already fixed in nightlystd::math::accumulate
returns zero if the end points "just after the file end".I can sum "all file bytes except last", but can't sum "all file bytes".
I looked at source code near https://github.com/WerWolv/PatternLanguage/blob/ImHex-v1.33.2/lib/source/pl/lib/std/math.cpp#L178 but failed to find the reason.
However, looking at source code I find that it has another bug: the end adress itself is divided by size, instead of dividing the adress difference. So summing from non-zero adress of non-single-byte elements fails.
Here are sample input and output as text on a simple file consisting of 16 identical bytes
0x01
I dont know what causes the bug with handling the last file byte, but the "non-zero start and >1 size" seems to be fixable by something like replacing
u128 endAddr = end / size;
byu128 endAddr = start + ((end - start) / size);
The text was updated successfully, but these errors were encountered: