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

Buffer overflow #38

Closed
zertyz opened this issue Dec 29, 2019 · 3 comments
Closed

Buffer overflow #38

zertyz opened this issue Dec 29, 2019 · 3 comments
Assignees
Labels

Comments

@zertyz
Copy link

zertyz commented Dec 29, 2019

Hello, my friend.

Thanks for sharing this wonderful package.

I found a little buffer overflow which goes unnoticed on x86_64, but prevents the libs from running at least on ARM32 (Raspberry Pi).

If you run one of the examples with the 'valgrind' memory leak & buffer overflow error detection tool, you will find that "JKQTPImageTools::getDefaultLUTs()" gives a series of invalid writes of 4 bytes each.

Inspecting the code at "lib/jkqtcommon/jkqtpbasicimagetools.cpp", I believe that the lines like:
plut[JKQTPImageTools::LUTSIZE+1]=plut[JKQTPImageTools::LUTSIZE];

are not necessary (the last element is already set on the loop... and the element at JKQTPImageTools::LUTSIZE+1 seems to be out of bounds, since, for what I understood, you allocate an array with that same size).

On Raspberry Pi 1, loading the libraries fail with the message:
malloc(): corrupted top size
Aborted (core dumped)
... indicating that the overflow corrupted the heap. A hard to follow issue without valgrind.

After deleting these lines, everything seems to run as intended both on x86_64 (linux) and Raspberry Pi.

Hope this report helps you to inspect the issue.

@jkriege2
Copy link
Owner

jkriege2 commented Jan 6, 2020

hi!

thanks for noting and reporting this bug ... I fixed it with this commit: d9086e9

Could yo confirm that it works now?

Thanks,
JAN

@zertyz
Copy link
Author

zertyz commented Jan 10, 2020

Yes. Thank you.

@jkriege2
Copy link
Owner

great!

thanks for checking!

Best,
JAN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants