summaryrefslogtreecommitdiffstats
path: root/src/file_rx2.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-07-26 22:42:10 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-07-26 22:42:10 +0200
commita2893357d2502e1e15a4ed2ac8c5f76af7cd63f2 (patch)
tree02bcea92051881d86a3f79fe921cd3210be1ba46 /src/file_rx2.c
parentc2af34417fa2c1ae42a07704de3a44e95fa5e3bc (diff)
PhotoRec: stricter check for .rx2
Diffstat (limited to 'src/file_rx2.c')
-rw-r--r--src/file_rx2.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/file_rx2.c b/src/file_rx2.c
index c12b635..0c8a0b5 100644
--- a/src/file_rx2.c
+++ b/src/file_rx2.c
@@ -53,18 +53,15 @@ struct rx2_header
static int header_check_rx2(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
- if(memcmp(&buffer[0], rx2_header, sizeof(rx2_header))==0 &&
- memcmp(&buffer[8], "REX2HEAD", 8)==0)
- {
- const struct rx2_header *rx2=(const struct rx2_header *)buffer;
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_rx2.extension;
- file_recovery_new->calculated_file_size=(uint64_t)be32(rx2->size)+8;
- file_recovery_new->data_check=&data_check_size;
- file_recovery_new->file_check=&file_check_size;
- return 1;
- }
- return 0;
+ const struct rx2_header *rx2=(const struct rx2_header *)buffer;
+ if(memcmp(&buffer[8], "REX2HEAD", 8)!=0 || be32(rx2->size) < 4)
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_rx2.extension;
+ file_recovery_new->calculated_file_size=(uint64_t)be32(rx2->size)+8;
+ file_recovery_new->data_check=&data_check_size;
+ file_recovery_new->file_check=&file_check_size;
+ return 1;
}
static void register_header_check_rx2(file_stat_t *file_stat)