seladb / PcapPlusPlus

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.
https://pcapplusplus.github.io/
The Unlicense
2.68k stars 650 forks source link

PointerVector's copy constructor/assignment can potentially introduce object slicing. #1549

Closed Dimi1010 closed 6 hours ago

Dimi1010 commented 3 weeks ago

The current implementation of PointerVector<T> contains a copy constructor/assignment that does a deep copy of all elements.

The issue is that the element wise copy is done via T* x = new T(*elemIt) which would slice off any polymorphic types held in the vector via a pointer to a base type.

A potential twofold solution can be: