From: Felix Fietkau Date: Mon, 4 Dec 2023 18:56:14 +0000 (+0100) Subject: lib-ucode: truncate pcap files X-Git-Url: http://git.openwrt.org/openwrt/openwrt.git%24%28if?a=commitdiff_plain;h=e259bbd49cf7b074a2ade5e62351e4e8f5fd76aa;p=project%2Fudebug.git lib-ucode: truncate pcap files avoid keeping stale data Signed-off-by: Felix Fietkau --- 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);