This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
Fix malloc off-by-one seg fault due to not accounting for the null terminator #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We experienced a crash when running the latest master with a simplified decoded backtrace of:
free (cursorname) on line 72 of fw1-cursor.c
open_fw1_cursorfile()
main()
Raw:
*** glibc detected *** /usr/local/bin/fw1-loggrabber: free(): invalid next size (fast): 0x08494768 ***
======= Backtrace: =========
/lib/libc.so.6(+0x70bb1)[0xf742abb1]
/lib/libc.so.6(+0x73611)[0xf742d611]
/usr/local/bin/fw1-loggrabber[0x804e098]
/usr/local/bin/fw1-loggrabber[0x804f432]
/lib/libc.so.6(__libc_start_main+0xe6)[0xf73d0d26]
/usr/local/bin/fw1-loggrabber[0x804d361]
From a review of how cursorname is constructed in get_fw1_cursorname(), it appears that the malloc is one byte too small since ".cursor" is 7 bytes and the NULL terminator is 1 byte. Therefore, it should be:
instead of:
The fix provided attempts to do the +8 in a more maintainable way by preventing needing to actually count the bytes in ".cursor".