Skip to content

[Bug] tcprewrite: Setting infile and outfile to the same file leads to truncation. #914

@wesly2000

Description

@wesly2000

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:

  1. Use tcprewrite --pnat=192.168.5.0/24:10.4.0.0/24 --infile=xxx.pcapng --outfile=xxx.pcapng.
  2. The file xxx.pcapng would 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:
The original file content

After using tcprewrite for IP address modification in a in-place manner:
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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions