image: Fix image_read() function when image has padding

This commit is contained in:
Pali Rohár committed 2023-05-07 22:38:36 +02:00
1 parent b67949fb5d
commit 9c608021f8
1 file changed
+4 -1
+4 -1
View File
@@ -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;