Skip to content

Commit

Permalink
tasks/elf: Handle vfs_seek errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lutoma committed Nov 15, 2023
1 parent 1bcca17 commit 24b66f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tasks/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 24b66f3

Please sign in to comment.