image: Fix image_read() function when image has padding
This commit is contained in:
1 parent
b67949fb5d
commit
9c608021f8
1 file changed
+4
-1
+4
-1
@@ -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 )
|
if ( count > image_fd->align )
|
||||||
new_count = image_fd->align;
|
new_count = image_fd->align;
|
||||||
else
|
else
|
||||||
new_count = count;
|
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);
|
memset(buf, 0xFF, new_count);
|
||||||
ret = new_count;
|
ret = new_count;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user