-
Notifications
You must be signed in to change notification settings - Fork 268
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
Error buffer always empty #532
Comments
The fact that a specific version of pcap in a specific OS returns an empty buffer, does not mean future versions will do so as well. The allocation size of 256, is part of the libpcap API, not respecting it, could lead to memory corruption. |
I can see in the custom marshaler that there is a proper string. I mean "more" than 256, 256 would be enough. I just ask, because it could be that other pcap implementations need that. |
I assume by custom marshaler, you are referring to PcapStringMarshaler, it only exists to handle the fact that different operating systems could use different strings encodings, this has no effect on size, except adding 1 byte for '\0' string termination. there are only 3 pcap implementations I am aware of, libpcap, WinPcap and Npcap and all of them comply with libpcap API, what other implementations are you referring to? I don't really get where you see that more than 256 bytes are being allocated. |
This too much allocation happens just for The important fact is that the marshaler is not able to return something for |
Ok, I get that the custom marshaler is over allocating, but that should not have performance or functionality side effects, a PR to fix that is welcome.
I don't get what you are trying to do here, or what problem you are running into. |
@trivalik Ok, I was able to reproduce the problem, the StringBuilder not getting the data back had absolutely nothing with the allocated memory size. It seems to be a limitation of ICustomMarshaler API, silently hiding the problem. |
I tested only on windows with npcap 1.79 and found that the error buffer is always empty returned. This could be easily tested by:
Does it make sense to allocated more memory than 256 for error buffer in the custom marshaler ?
The text was updated successfully, but these errors were encountered: