From 6d3f51f9fda706f0cf4732c762e4dbe8c21e12cf Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 6 Dec 2023 14:00:35 +0100 Subject: [PATCH] ucode: check for errors in ftruncate() Signed-off-by: Felix Fietkau --- lib-ucode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib-ucode.c b/lib-ucode.c index d50fd90..c2ce3b2 100644 --- a/lib-ucode.c +++ b/lib-ucode.c @@ -327,7 +327,10 @@ uc_udebug_pcap_file(uc_vm_t *vm, size_t nargs) if (ucv_type(file) == UC_STRING) { fd = open(ucv_string_get(file), O_WRONLY | O_CREAT, 0644); - ftruncate(fd, 0); + if (ftruncate(fd, 0) < 0) { + close(fd); + return NULL; + } } else if (!file) fd = STDOUT_FILENO; -- 2.30.2