From 24b66f30c71bc30f7bc0c699984a8973bb4c2f73 Mon Sep 17 00:00:00 2001 From: Lukas Martini Date: Wed, 15 Nov 2023 17:14:58 +0100 Subject: [PATCH] tasks/elf: Handle vfs_seek errors --- src/tasks/elf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tasks/elf.c b/src/tasks/elf.c index 53beae63..35034527 100644 --- a/src/tasks/elf.c +++ b/src/tasks/elf.c @@ -40,7 +40,11 @@ static char elf_magic[16] = {0x7f, 'E', 'L', 'F', 01, 01, 01, 0, 0, 0, 0, 0, 0, static inline void* bin_read(int fd, size_t offset, size_t size, void* inbuf, task_t* task) { void* buf = inbuf ? inbuf : kmalloc(size); - vfs_seek(task, fd, offset, VFS_SEEK_SET); + if(vfs_seek(task, fd, offset, VFS_SEEK_SET) < 0 ) { + debug("elf: bin_read: vfs_seek failed\n"); + return NULL; + } + size_t read = vfs_read(task, fd, buf, size); if(likely(read == size)) { return buf;