diff --git a/core/cfs/cfs-coffee.c b/core/cfs/cfs-coffee.c index 6391e173c..07df6121b 100644 --- a/core/cfs/cfs-coffee.c +++ b/core/cfs/cfs-coffee.c @@ -1098,8 +1098,8 @@ cfs_read(int fd, void *buf, unsigned size) fdp = &coffee_fd_set[fd]; file = fdp->file; - if(fdp->offset + size > file->end) { - size = file->end - fdp->offset; + while(fdp->offset + size > file->end) { + ((char*)buf)[--size] = 0; } /* If the file is not modified, read directly from the file extent. */