From 1212037a51bd98b9e30e1b08c73cf401d02ccedc Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sat, 20 Feb 2021 15:05:38 +0100 Subject: [PATCH] src/file_fds.c: add frama-c annotations --- src/file_fds.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/file_fds.c b/src/file_fds.c index 2ec3c4b1..3a18d159 100644 --- a/src/file_fds.c +++ b/src/file_fds.c @@ -32,8 +32,8 @@ #include "filegen.h" #include "common.h" +/*@ requires \valid(file_stat); */ static void register_header_check_fds(file_stat_t *file_stat); -static int header_check_fds(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_fds= { .extension="fds", @@ -50,6 +50,17 @@ struct fds_header uint8_t numsides; } __attribute__ ((gcc_struct, __packed__)); +/*@ + @ requires buffer_size > 0; + @ 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_fds, buffer+(..), file_recovery, file_recovery_new); + @ ensures \result == 0 || \result == 1; + @ ensures \result!=0 ==> valid_file_recovery(file_recovery_new); + @ assigns *file_recovery_new; + @*/ static int header_check_fds(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 struct fds_header *bm=(const struct fds_header *)buffer; @@ -57,7 +68,7 @@ static int header_check_fds(const unsigned char *buffer, const unsigned int buff reset_file_recovery(file_recovery_new); file_recovery_new->extension=file_hint_fds.extension; file_recovery_new->min_filesize=16; - file_recovery_new->calculated_file_size=(uint64_t)size; + file_recovery_new->calculated_file_size=size; file_recovery_new->data_check=&data_check_size; file_recovery_new->file_check=&file_check_size; return 1;