-
Notifications
You must be signed in to change notification settings - Fork 29
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
Initialization of buffer in hashing.h is wrong, causing crash when extracting TrackIR firmware #200
Comments
Created a pull-request to fix this problem. I am not sure if should close this topic as of yet ... |
Nice fix. |
Hello, Kind regards, Michal |
I agree code looks like it should work either way but i think this fixed the firmware extraction crash for me too. Maybe the problem is elsewhere and this just happens to move things around. |
I do not see any allocation of the buffer, therefore it crashes. |
Sorry, I was wrong about this. It seems reserve does allocate memory! Though, I think the difference is that when doing reserve, it only allocates memory, but does not size the array. Using resize(), allocates the array, and sets the size of the array. So you can access all the elements in the array. |
Well then i am "pointing you" as you are wrong. |
Then I am as confused as you are. As the change I made fixed the problem. 😝 |
A code change in unrelated sections of a program can move around memory placement, so there probably is a use after free, reference to old stack variable or a out of bounds bug somewhere that became non-crashing with this change. Valgrind should be able catch it if you want to give it a try. |
According to documentation, calling reserve only allocates memory (increasing its capacity size), it does not increase the vector size. |
Good thinking! It didn't occur to me... Michal |
In the constructor of FashHash in hashing.h, buffer is reserved, but not allocated.
Hence:
buffer.reserve(length);
should be replaced by:
buffer.resize(length);
This fixed my problem when extracting firmware for the TrackIR, causing the application to crash and fail the extraction.
With the above fix, it works.
The text was updated successfully, but these errors were encountered: