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

handle exception of getLdapOperationAsn1Record() in getLdapOperationType() #1617

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

1ndahous3
Copy link
Contributor

getLdapOperationAsn1Record() says:

If the Operation ASN.1 record is malformed, an exception is thrown

but getLdapOperationType() and it's callers don't care about exceptions (got abort on invalid data, added in fussing regression testcase).

File summary:
~~~~~~~~~~~~~
   File name: /home/user/crash-exception-cast-constructed-record
   File size: 972 bytes
   Link layer type: Ethernet

Packet length: 259 [Bytes], Arrival time: 2021-08-06 09:52:05.825996000
IEEE 802.3 Ethernet, Src: 36:00:00:00:36:00, Dst: 32:23:03:00:00:00
Logical Link Control
Payload Layer, Data length: 242 [Bytes]

terminate called after throwing an instance of 'std::bad_cast'
  what():  std::bad_cast
==2301031== 
==2301031== Process terminating with default action of signal 6 (SIGABRT)
==2301031==    at 0x4CC3E5C: __pthread_kill_implementation (pthread_kill.c:44)
==2301031==    by 0x4C6FC81: raise (raise.c:26)
==2301031==    by 0x4C584EF: abort (abort.c:79)
==2301031==    by 0x4956A3C: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.33)
==2301031==    by 0x4968009: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.33)
==2301031==    by 0x49565E8: std::terminate() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.33)
==2301031==    by 0x4968287: __cxa_throw (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.33)
==2301031==    by 0x1241C6: pcpp::Asn1SetRecord* pcpp::Asn1Record::castAs<pcpp::Asn1SetRecord>() [clone .part.0] (in /home/user/git/PcapPlusPlus/build/examples_bin/PcapPrinter)
==2301031==    by 0x1242CA: pcpp::LdapLayer::getLdapOperationAsn1Record() const [clone .cold] (in /home/user/git/PcapPlusPlus/build/examples_bin/PcapPrinter)
==2301031==    by 0x1A11E8: pcpp::LdapLayer::getLdapOperationType() const (in /home/user/git/PcapPlusPlus/build/examples_bin/PcapPrinter)
==2301031==    by 0x1A03F0: pcpp::LdapLayer::toString[abi:cxx11]() const (in /home/user/git/PcapPlusPlus/build/examples_bin/PcapPrinter)
==2301031==    by 0x1544DB: pcpp::Packet::toStringList(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, bool) const (in /home/user/git/PcapPlusPlus/build/examples_bin/PcapPrinter)

@1ndahous3 1ndahous3 requested a review from seladb as a code owner October 20, 2024 11:46
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Project coverage is 83.15%. Comparing base (bdc68bd) to head (a8439f7).
Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
Packet++/src/LdapLayer.cpp 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1617      +/-   ##
==========================================
- Coverage   83.16%   83.15%   -0.02%     
==========================================
  Files         276      276              
  Lines       47288    47296       +8     
  Branches     9616     9651      +35     
==========================================
+ Hits        39326    39327       +1     
- Misses       7076     7081       +5     
- Partials      886      888       +2     
Flag Coverage Δ
fedora40 75.24% <50.00%> (-0.03%) ⬇️
macos-13 80.69% <66.66%> (-0.01%) ⬇️
macos-14 80.69% <66.66%> (-0.01%) ⬇️
macos-15 80.66% <66.66%> (-0.01%) ⬇️
mingw32 70.83% <50.00%> (-0.03%) ⬇️
mingw64 70.78% <50.00%> (-0.05%) ⬇️
npcap 85.12% <40.00%> (-0.10%) ⬇️
rhel94 75.09% <50.00%> (-0.03%) ⬇️
ubuntu2004 58.68% <66.66%> (-0.02%) ⬇️
ubuntu2004-zstd 58.79% <66.66%> (-0.03%) ⬇️
ubuntu2204 75.02% <50.00%> (-0.03%) ⬇️
ubuntu2204-icpx 61.52% <50.00%> (-0.01%) ⬇️
ubuntu2404 75.30% <50.00%> (-0.01%) ⬇️
unittest 83.15% <55.55%> (-0.02%) ⬇️
windows-2019 85.23% <57.14%> (-0.03%) ⬇️
windows-2022 85.25% <40.00%> (-0.03%) ⬇️
winpcap 85.21% <57.14%> (-0.02%) ⬇️
xdp 50.22% <50.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seladb seladb merged commit d3adb80 into seladb:dev Oct 23, 2024
41 checks passed
@seladb
Copy link
Owner

seladb commented Oct 23, 2024

Thank you @1ndahous3 for this fix, much appreciated! 🙏

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

Successfully merging this pull request may close these issues.

2 participants