From: Felix Fietkau Date: Wed, 6 Dec 2023 13:00:35 +0000 (+0100) Subject: ucode: check for errors in ftruncate() X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=6d3f51f9fda706f0cf4732c762e4dbe8c21e12cf;p=project%2Fudebug.git ucode: check for errors in ftruncate() Signed-off-by: Felix Fietkau --- 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;