Skip to content

Commit

Permalink
Detect empty GIF files
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaaaa123456789 committed Jan 22, 2022
1 parent 23e1c82 commit d2fc1f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Note: releases are listed from latest to oldest.
process to fail (the background is ignored instead if there are no available palette slots)
- Added some warning flags for debug builds, and cleared some warnings that would be raised by them
- Added and improved some safety checks that detect maliciously-crafted and other pathological files
- Added detection for empty GIF files (erroring out with `PLUM_ERR_NO_DATA` instead of `PLUM_ERR_INVALID_FILE_FORMAT`)
- Some minor documentation updates and code cleanup

## Version 0.3 (10 January 2022)
Expand Down
4 changes: 4 additions & 0 deletions src/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ struct plum_image * plum_load_image_limited (const void * restrict buffer, size_
}

void load_image_buffer_data (struct context * context, unsigned flags, size_t limit) {
if ((context -> size == 7) && (bytematch(context -> data, 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x3b) ||
bytematch(context -> data, 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x3b)))
// empty GIF file
throw(context, PLUM_ERR_NO_DATA);
if (context -> size < 8) throw(context, PLUM_ERR_INVALID_FILE_FORMAT);
if (bytematch(context -> data, 0x42, 0x4d))
load_BMP_data(context, flags, limit);
Expand Down

0 comments on commit d2fc1f9

Please sign in to comment.