You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's unclear if this current Clone impl is legal. There is nothing in https://npcap.com/guide/wpcap/pcap_compile.html or https://npcap.com/guide/wpcap/pcap_freecode.html that said the pointer is allocated with malloc, this mean that if pcap doesn't use malloc, freecode would not be aware we used malloc to clone the struct. This code is from a #[derive(Clone)] that was obviusly not working d610300 I think there is no need to have a Clone for this struct. I think the best would be to remove this Clone unless we have more information.
implCloneforBpfProgram{// make a deep copy of the underlying programfnclone(&self) -> Self{let len = self.0.bf_lenasusize;let size = len * mem::size_of::<raw::bpf_insn>();let storage = unsafe{let storage = libc::malloc(size)as*mut raw::bpf_insn;
ptr::copy_nonoverlapping(self.0.bf_insns, storage, len);
storage
};BpfProgram(raw::bpf_program{bf_len:self.0.bf_len,bf_insns: storage,})}}
The text was updated successfully, but these errors were encountered:
I did a bit of digging as to who/where this is being used and the original PR that proposed the change is here: #56. The PR points to https://github.com/LTD-Beget/syncookied as the project where it was being used. However, they've been using their own fork of pcap and the project stopped getting updates before pcap got picked up again. However, looking through its code, they never made use of clone anyway.
Therefore, if you think it is wrong, and it indeed looks wrong given that there's pcap_freecode, I'd just remove it.
It's unclear if this current Clone impl is legal. There is nothing in https://npcap.com/guide/wpcap/pcap_compile.html or https://npcap.com/guide/wpcap/pcap_freecode.html that said the pointer is allocated with malloc, this mean that if pcap doesn't use malloc, freecode would not be aware we used malloc to clone the struct. This code is from a
#[derive(Clone)]
that was obviusly not working d610300 I think there is no need to have a Clone for this struct. I think the best would be to remove this Clone unless we have more information.The text was updated successfully, but these errors were encountered: