From e259bbd49cf7b074a2ade5e62351e4e8f5fd76aa Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 4 Dec 2023 19:56:14 +0100 Subject: [PATCH] lib-ucode: truncate pcap files avoid keeping stale data Signed-off-by: Felix Fietkau --- lib-ucode.c | 5 +++-- 1 file 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); -- 2.30.2