-
Notifications
You must be signed in to change notification settings - Fork 705
Malformed packet with incorrect payload length in header caused exception #1829
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
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1829 +/- ##
========================================
Coverage 82.99% 82.99%
========================================
Files 284 284
Lines 48974 49004 +30
Branches 10576 10347 -229
========================================
+ Hits 40647 40672 +25
- Misses 7178 7218 +40
+ Partials 1149 1114 -35
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@bratbiswas thanks for contributing this fix! 🙏 Since you already have a malformed pcap that causes this crash (attached to the issue), can you add a test here? https://github.com/seladb/PcapPlusPlus/blob/master/Tests/Pcap%2B%2BTest/Tests/IPFragmentationTests.cpp You can find more info on how to run tests here: https://pcapplusplus.github.io/docs/tests Let me know if you need my help with writing the test. |
7185411
to
cfdcf63
Compare
I committed three files - main.cpp, TestDefinition.h and IPFragmentationTests.cpp. I followed instruction from chatgpt and added "--force-with-lease" flag in the push and the changes were pushed but now I see changes in a lot more files than I actually added/committed! I am sorry for the mess. One really needs a phd on git to be able to use it! I mean source control seems a lot more complicated than writing the software itself :-( |
gettimeofday(&time, nullptr); | ||
|
||
int bufferLength = 0; | ||
uint8_t* buffer = readFileIntoBuffer("PcapExamples/ip4_bad_fragment.txt", bufferLength); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you also need to push the file "PcapExamples/ip4_bad_fragment.txt"
?
Maybe instead you can push a pcap file that contains this packet?
Since *.pcap
is in .gitignore
you need to use the -f
flag:
git add -f Tests/Pcap++Test/PcapExamples/ip4_bad_fragment.pcap
git commit -m "Add pcap file"
If you add a pcap file you can use pcpp::PcapFileReaderDevice
to read it, like we do here:
pcpp::PcapFileReaderDevice reader("PcapExamples/ip6_fragments.pcap"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Modified the code to use a PCAP and added the PCAP too.
gettimeofday(&time, nullptr); | ||
|
||
int bufferLength = 0; | ||
uint8_t* buffer = readFileIntoBuffer("PcapExamples/ip4_bad_fragment.txt", bufferLength); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you also have an example of a malformed IPv6 packet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't have an IPv6 packet.
When a malformed IP packet looks like a fragment and contains an invalid payload length in the header, the IPRessembly class trusts the payload length in header and can cause an exception if the length is more than the real length of the payload. A check is introduced validate the lengths and return MALFORMED_PACKET if things are not right.