diff --git a/src/file_dir.c b/src/file_dir.c index d1900932..1abbf0f3 100644 --- a/src/file_dir.c +++ b/src/file_dir.c @@ -35,10 +35,9 @@ #include "filegen.h" #include "common.h" #include "fat_common.h" -#include "fat_dir.h" +/*@ requires \valid(file_stat); */ static void register_header_check_dir(file_stat_t *file_stat); -static int header_check_dir(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); const file_hint_t file_hint_dir= { .extension="fat", @@ -51,7 +50,7 @@ const file_hint_t file_hint_dir= { /*@ @ requires \valid(file_recovery); - @ requires valid_read_string((char*)&file_recovery->filename); + @ requires valid_file_recovery(file_recovery); @ requires file_recovery->file_rename==&file_rename_fatdir; @*/ static void file_rename_fatdir(file_recovery_t *file_recovery) @@ -78,6 +77,7 @@ static void file_rename_fatdir(file_recovery_t *file_recovery) @ requires \valid_read((char *)buffer+(0..buffer_size-1)); @ requires \valid(file_recovery); @ requires file_recovery->data_check == &data_check_fatdir; + @ requires file_recovery->calculated_file_size <= PHOTOREC_MAX_FILE_SIZE; @ ensures \result == DC_STOP; @ assigns file_recovery->calculated_file_size; @*/ @@ -91,11 +91,12 @@ static data_check_t data_check_fatdir(const unsigned char *buffer, const unsigne /*@ @ requires buffer_size >= sizeof(struct msdos_dir_entry); @ requires \valid_read(buffer+(0..buffer_size-1)); - @ requires \valid_read(file_recovery); - @ requires file_recovery->file_stat==\null || valid_read_string((char*)file_recovery->filename); + @ requires valid_file_recovery(file_recovery); @ requires \valid(file_recovery_new); @ requires file_recovery_new->blocksize > 0; @ requires separation: \separated(&file_hint_dir, buffer+(..), file_recovery, file_recovery_new); + @ assigns *file_recovery_new; + @ ensures \result!=0 ==> valid_file_recovery(file_recovery_new); @*/ static int header_check_dir(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) { @@ -111,9 +112,6 @@ static int header_check_dir(const unsigned char *buffer, const unsigned int buff return 1; } -/*@ - @ requires \valid(file_stat); - @*/ static void register_header_check_dir(file_stat_t *file_stat) { register_header_check(0, ". ", 8+3, &header_check_dir, file_stat);