diff options
| author | Felix Fietkau | 2023-12-06 13:00:35 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2023-12-06 13:00:35 +0000 |
| commit | 6d3f51f9fda706f0cf4732c762e4dbe8c21e12cf (patch) | |
| tree | a8c459d95cc50ec6697cba3b85db44aad9d59467 | |
| parent | a296f1bac4302c2102a0d2fd1e825c4dadddf0f4 (diff) | |
ucode: check for errors in ftruncate()
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | lib-ucode.c | 5 |
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; |