mirror of
https://github.com/limine-bootloader/limine
synced 2025-01-21 03:52:04 +03:00
bmp: Ensure that bf_offset + bf_size <= file size
This commit is contained in:
parent
5374e4e1f2
commit
b7176d5cfa
@ -40,7 +40,15 @@ int bmp_open_image(struct image *image, struct file_handle *file) {
|
||||
return -1;
|
||||
|
||||
image->img = ext_mem_alloc(header.bf_size);
|
||||
fread(file, image->img, header.bf_offset, header.bf_size);
|
||||
|
||||
uint32_t bf_size;
|
||||
if (header.bf_offset + header.bf_size > file->size) {
|
||||
bf_size = file->size - header.bf_offset;
|
||||
} else {
|
||||
bf_size = header.bf_size;
|
||||
}
|
||||
|
||||
fread(file, image->img, header.bf_offset, bf_size);
|
||||
|
||||
image->x_size = header.bi_width;
|
||||
image->y_size = header.bi_height;
|
||||
|
Loading…
Reference in New Issue
Block a user