diff options
| author | Felix Fietkau | 2023-12-04 18:56:14 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2023-12-04 18:56:16 +0000 |
| commit | e259bbd49cf7b074a2ade5e62351e4e8f5fd76aa (patch) | |
| tree | e877a38153914c6ab64f5ab54e7d40d43c49e581 | |
| parent | c7ef98d3d3f715ad2cea80b9d67b2c058209a545 (diff) | |
lib-ucode: truncate pcap files
avoid keeping stale data
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | lib-ucode.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib-ucode.c b/lib-ucode.c index 8e042e3..d50fd90 100644 --- a/lib-ucode.c +++ b/lib-ucode.c @@ -325,9 +325,10 @@ uc_udebug_pcap_file(uc_vm_t *vm, size_t nargs) uc_value_t *args = uc_fn_arg(1); int fd = -1; - if (ucv_type(file) == UC_STRING) + if (ucv_type(file) == UC_STRING) { fd = open(ucv_string_get(file), O_WRONLY | O_CREAT, 0644); - else if (!file) + ftruncate(fd, 0); + } else if (!file) fd = STDOUT_FILENO; return uc_debug_pcap_init(fd, args); |