Skip to content
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

pcap_dump should return -1 on fwrite error #1047

Open
rigtorp opened this issue Aug 24, 2021 · 3 comments · May be fixed by #1048
Open

pcap_dump should return -1 on fwrite error #1047

rigtorp opened this issue Aug 24, 2021 · 3 comments · May be fixed by #1048

Comments

@rigtorp
Copy link

rigtorp commented Aug 24, 2021

Currently it's cumbersome to detect if there was an error when writing to a dump file. You need to use pcap_dump_fopen(stream) and then check ferror(stream) after each call to pcap_dump. A better solution would be to return -1 from pcap_dump on any error. Given the C ABI on x32 and x64 it's safe to modify this call to return an int, maybe not on all platforms? Safest solution would be to add a int pcap_dump2(...). What do you think?

@mcr
Copy link
Member

mcr commented Aug 25, 2021

We could do that, but it's not enough in the end.
That's because some errors (like NFS ones, and other clustering systems) aren't returned until you fclose() the file.
The dump API needs a major overhaul, but I don't object to either solution.

@rigtorp
Copy link
Author

rigtorp commented Aug 25, 2021 via email

@rigtorp rigtorp linked a pull request Aug 25, 2021 that will close this issue
5 tasks
@guyharris
Copy link
Member

This should be provided with any new file-writing APIs added for issue #1321.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants