summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2023-12-06 13:00:35 +0000
committerFelix Fietkau2023-12-06 13:00:35 +0000
commit6d3f51f9fda706f0cf4732c762e4dbe8c21e12cf (patch)
treea8c459d95cc50ec6697cba3b85db44aad9d59467
parenta296f1bac4302c2102a0d2fd1e825c4dadddf0f4 (diff)
ucode: check for errors in ftruncate()
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--lib-ucode.c5
1 files changed, 4 insertions, 1 deletions
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;