-
Notifications
You must be signed in to change notification settings - Fork 289
[Bug] tcprewrite: Setting infile and outfile to the same file leads to truncation. #914
Description
Describe the bug
When rewrite IP address for a .pcap file using tcprewrite, if I set --infile and --outfile to the same filename, the output file seems to be truncated (the original file contains 27 packets but the output file contains only 4 pacekts. This would happen for --pnat and -e options.
To Reproduce
Steps to reproduce the behavior:
- Use
tcprewrite --pnat=192.168.5.0/24:10.4.0.0/24 --infile=xxx.pcapng --outfile=xxx.pcapng. - The file
xxx.pcapngwould be truncated to have few pacekts.
Expected behavior
The resulting .pcap file should not be truncated, but only IP modified. I'm not sure if the in-place modification is not supported or a bug. Since I have many .pcap files, setting --infile and --outfile to different files would occupy much space. Currently a quick workaround for me is to write a script which use different --infile and --outfile and then delete the --infile.
I'm sorry that I didn't find similar issues here or on Stack Overflow. Any suggestions are appreciated! :)
Screenshots
The original file content:

After using tcprewrite for IP address modification in a in-place manner:

System (please complete the following information):
- OS: Ubuntu
- OS version 20.04.6 LTS
- Tcpreplay Version 4.3.2 (installed using
apt install)
Additional context
Add any other context about the problem here.