-
Notifications
You must be signed in to change notification settings - Fork 868
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
do NOT close fp in pcap_close call when the fp obtained via pcap_fopen_offline #1375
Comments
Yes, it will, and that behavior dates back to libpcap 0.9, when Changing it would break the API and ABI contracts that libpcap offers to its callers; that could, for example, leak the If there is code that uses libpcap and nees to use the (When a |
I will update the |
thanks~ |
I.e., if you use pcap_fopen_offline() or pcap_fopen_offline_with_tstamp_precision() to open a file, unless you passed stdin as an argument, the FILE * you passed will be closed when pcap_close() is called. Also note the equivalent behavior for pcap_dump_close(). See #1375.
I.e., if you use pcap_fopen_offline() or pcap_fopen_offline_with_tstamp_precision() to open a file, unless you passed stdin as an argument, the FILE * you passed will be closed when pcap_close() is called. Also note the equivalent behavior for pcap_dump_close(). See #1375. (cherry picked from commit 40d6d0f)
I've updated the documentation. I've also changed |
maybe new routines like pcap_close_without_fp will be more helpful |
One potential way to do this would be using a new function generalised from #1374 such as |
Where is this useful? And, if it is, it should probably be specified at open time, not close time; |
let the code calling libpcap take the responsibility of managing the FILE * . of course pcap_close_without_fp() should NOT be called if pcap_open_offline() call earilier. |
Either
or
Doing so at open ime is preferable, for the reasons I mentioned.
That imposes a requirement on the programmer to remember which At the cost of one flag in the data to which the |
@crackevil, if you see a problem and expect a solution, please explain the use case in detail. |
in my case, I want libpcap read pcap file content from a pipe opened by other component. since libpcap did not open the FILE* so it should not close it. the action of the write end of the pipe is not predicable when libpcap close the FILE* of the read end of the pipe. |
Thank you. |
Yes,
So presumably the process reading from the pipe may stop reading and close the
And whoever calls But it's not obvious that the programmer will get it right. The question is which produces code that's clearer to read (associating the "don't close the |
libpcap version: 1.10.4 on windows.
calling pcap_close will close the fp which opened before pcap_fopen_offline.
the pcap_dump_close routine has the same issue.
The text was updated successfully, but these errors were encountered: