summaryrefslogtreecommitdiffstats
path: root/src/file_ico.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-05-21 09:01:07 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2010-05-21 09:01:07 +0200
commite9d4598c2bed3a653c83f2fe5c44b52cb4835dc0 (patch)
tree3ffeb9da19a60cb1bce6e5b7d840112b6bf222b3 /src/file_ico.c
parenta8ea983693475107c463907af944280b0a719326 (diff)
PhotoRec: stricter check for .ico
Diffstat (limited to 'src/file_ico.c')
-rw-r--r--src/file_ico.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/file_ico.c b/src/file_ico.c
index 9a3ed56..fe782d8 100644
--- a/src/file_ico.c
+++ b/src/file_ico.c
@@ -86,13 +86,17 @@ static int header_check_ico(const unsigned char *buffer, const unsigned int buff
(ico_dir->reserved==0 || ico_dir->reserved==255) &&
(ico_dir->color_planes==0 || ico_dir->color_planes==1) &&
ico_dir->width==ico_dir->heigth &&
- ico_dir->width>=16
-
- )
+ ico_dir->width>=16 &&
+ (le16(ico_dir->bits_per_pixel)==1 ||
+ le16(ico_dir->bits_per_pixel)==4 ||
+ le16(ico_dir->bits_per_pixel)==8 ||
+ le16(ico_dir->bits_per_pixel)==16 ||
+ le16(ico_dir->bits_per_pixel)==32) &&
+ le32(ico_dir->bitmap_offset) >= sizeof(struct ico_header)+le16(ico->count)*sizeof(struct ico_directory))
{
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_ico.extension;
- file_recovery_new->calculated_file_size=le32(ico_dir->bitmap_size) + le32(ico_dir->bitmap_offset);
+ file_recovery_new->calculated_file_size=(uint64_t)le32(ico_dir->bitmap_size) + le32(ico_dir->bitmap_offset);
file_recovery_new->data_check=&data_check_size;
file_recovery_new->file_check=&file_check_size;
return 1;