diff --git a/src/file_crw.c b/src/file_crw.c index 7fc5c976..879f20d8 100644 --- a/src/file_crw.c +++ b/src/file_crw.c @@ -32,9 +32,8 @@ #include "filegen.h" #include "log.h" +/*@ requires \valid(file_stat); */ static void register_header_check_crw(file_stat_t *file_stat); -static int header_check_crw(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); -static void file_check_crw(file_recovery_t *file_recovery); const file_hint_t file_hint_crw= { .extension="crw", @@ -45,15 +44,23 @@ const file_hint_t file_hint_crw= { .register_header_check=®ister_header_check_crw }; -static const unsigned char crw_header_be[2]= {'I','I'}; -static const unsigned char crw_header_le[2]= {'M','M'}; - -static void register_header_check_crw(file_stat_t *file_stat) +static void file_check_crw(file_recovery_t *file_recovery) { - register_header_check(0, crw_header_be, sizeof(crw_header_be), &header_check_crw, file_stat); - register_header_check(0, crw_header_le, sizeof(crw_header_le), &header_check_crw, file_stat); + const unsigned char crw_footer[2]= { 0x0A, 0x30}; + file_search_footer(file_recovery, crw_footer, sizeof(crw_footer), 12); } +/*@ + @ requires buffer_size >= 6+8; + @ requires \valid_read(buffer+(0..buffer_size-1)); + @ requires valid_file_recovery(file_recovery); + @ requires \valid(file_recovery_new); + @ requires file_recovery_new->blocksize > 0; + @ requires separation: \separated(&file_hint_crw, buffer+(..), file_recovery, file_recovery_new); + @ assigns *file_recovery_new; + @ ensures \result == 0 || \result == 1; + @ ensures \result!=0 ==> valid_file_recovery(file_recovery_new); + @*/ static int header_check_crw(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(((buffer[0]==0x49 && buffer[1]==0x49)||(buffer[0]==0x4D && buffer[1]==0x4D)) @@ -67,9 +74,13 @@ static int header_check_crw(const unsigned char *buffer, const unsigned int buff return 0; } -static void file_check_crw(file_recovery_t *file_recovery) +static void register_header_check_crw(file_stat_t *file_stat) { - const unsigned char crw_footer[2]= { 0x0A, 0x30}; - file_search_footer(file_recovery, crw_footer, sizeof(crw_footer), 12); + static const unsigned char crw_header_be[2]= {'I','I'}; + static const unsigned char crw_header_le[2]= {'M','M'}; + register_header_check(0, crw_header_be, sizeof(crw_header_be), &header_check_crw, file_stat); +#ifndef __FRAMAC__ + register_header_check(0, crw_header_le, sizeof(crw_header_le), &header_check_crw, file_stat); +#endif } #endif