src/file_bvr.c: add missing frama-c annotations
This commit is contained in:
parent
63d53f1a35
commit
0bcffdf162
1 changed files with 24 additions and 2 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "filegen.h"
|
#include "filegen.h"
|
||||||
|
|
||||||
|
/*@ requires \valid(file_stat); */
|
||||||
static void register_header_check_bvr(file_stat_t *file_stat);
|
static void register_header_check_bvr(file_stat_t *file_stat);
|
||||||
|
|
||||||
const file_hint_t file_hint_bvr= {
|
const file_hint_t file_hint_bvr= {
|
||||||
|
@ -42,6 +43,17 @@ const file_hint_t file_hint_bvr= {
|
||||||
.register_header_check=®ister_header_check_bvr
|
.register_header_check=®ister_header_check_bvr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*@
|
||||||
|
@ requires buffer_size > 0;
|
||||||
|
@ requires (buffer_size&1)==0;
|
||||||
|
@ requires \valid_read(buffer+(0..buffer_size-1));
|
||||||
|
@ requires \valid(file_recovery);
|
||||||
|
@ requires file_recovery->data_check==&data_check_bvr;
|
||||||
|
@ requires file_recovery->calculated_file_size <= PHOTOREC_MAX_FILE_SIZE;
|
||||||
|
@ requires \separated(buffer, file_recovery);
|
||||||
|
@ ensures \result == DC_CONTINUE || \result == DC_STOP;
|
||||||
|
@ assigns file_recovery->calculated_file_size;
|
||||||
|
@*/
|
||||||
static data_check_t data_check_bvr(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
|
static data_check_t data_check_bvr(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
|
||||||
{
|
{
|
||||||
/*@
|
/*@
|
||||||
|
@ -50,17 +62,27 @@ static data_check_t data_check_bvr(const unsigned char *buffer, const unsigned i
|
||||||
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
|
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
|
||||||
file_recovery->calculated_file_size + 16 < file_recovery->file_size + buffer_size/2)
|
file_recovery->calculated_file_size + 16 < file_recovery->file_size + buffer_size/2)
|
||||||
{
|
{
|
||||||
const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
|
const unsigned int i=file_recovery->calculated_file_size + buffer_size/2 - file_recovery->file_size;
|
||||||
|
/*@ assert 0 <= i < buffer_size - 16; */
|
||||||
const uint32_t *valp=(const uint32_t *)&buffer[i+12];
|
const uint32_t *valp=(const uint32_t *)&buffer[i+12];
|
||||||
if(memcmp(&buffer[i], "BLUE", 4) != 0)
|
if(memcmp(&buffer[i], "BLUE", 4) != 0)
|
||||||
return DC_STOP;
|
return DC_STOP;
|
||||||
file_recovery->calculated_file_size+=0x20 + *valp;
|
file_recovery->calculated_file_size+=(uint64_t)0x20 + *valp;
|
||||||
if(*valp == 0)
|
if(*valp == 0)
|
||||||
return DC_STOP;
|
return DC_STOP;
|
||||||
}
|
}
|
||||||
return DC_CONTINUE;
|
return DC_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*@
|
||||||
|
@ 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_bvr, buffer+(..), file_recovery, file_recovery_new);
|
||||||
|
@ ensures \result!=0 ==> valid_file_recovery(file_recovery_new);
|
||||||
|
@*/
|
||||||
static int header_check_bvr(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 int header_check_bvr(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(file_recovery->file_stat!=NULL &&
|
if(file_recovery->file_stat!=NULL &&
|
||||||
|
|
Loading…
Reference in a new issue