diff --git a/src/image.c b/src/image.c index 37fa32f..234329e 100644 --- a/src/image.c +++ b/src/image.c @@ -528,13 +528,16 @@ size_t image_read(struct image * image, void * buf, size_t count) { } - if ( image_fd->align > 0 && count > 0 ) { + if ( image_fd->align > 0 && count > 0 && image->cur < start + image_fd->size ) { if ( count > image_fd->align ) new_count = image_fd->align; else new_count = count; + if ( image->cur + new_count > start + image_fd->size ) + new_count = start + image_fd->size - image->cur; + memset(buf, 0xFF, new_count); ret = new_count;