mfontanini / libtins

High-level, multiplatform C++ network packet sniffing and crafting library.
http://libtins.github.io/
BSD 2-Clause "Simplified" License
1.9k stars 375 forks source link

Packet Writer move semantics may produce segfault #428

Open ghost opened 3 years ago

ghost commented 3 years ago

I noticed that the Packet Writer class provides a move assignment operator that sets the moved-from object's pcap-handles in a null state. Any further calls to write on the moved-from object should result in a segfault.

This might have been a concious decision, but the issue could be avoided by placing a check for non-null pcap-handles in the write method. Would you be interested in a PR, or are you happy to leave it as-is?

mfontanini commented 3 years ago

That should work! Ideally this would throw some new type of exception. A PR would be great :)