src/file_mb.c: add frama-c annotations
This commit is contained in:
parent
46206cedf9
commit
1b0a138bbc
1 changed files with 26 additions and 2 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include "filegen.h"
|
#include "filegen.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
/*@ requires \valid(file_stat); */
|
||||||
static void register_header_check_mb(file_stat_t *file_stat);
|
static void register_header_check_mb(file_stat_t *file_stat);
|
||||||
|
|
||||||
const file_hint_t file_hint_mb= {
|
const file_hint_t file_hint_mb= {
|
||||||
|
@ -50,20 +51,43 @@ struct maya_header
|
||||||
char magic2[8];
|
char magic2[8];
|
||||||
} __attribute__ ((gcc_struct, __packed__));
|
} __attribute__ ((gcc_struct, __packed__));
|
||||||
|
|
||||||
|
/*@
|
||||||
|
@ requires buffer_size >= sizeof(struct maya_header);
|
||||||
|
@ 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_mb, 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_mb(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_mb(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 maya_header *hdr=(const struct maya_header *)buffer;
|
const struct maya_header *hdr=(const struct maya_header *)buffer;
|
||||||
if(memcmp(buffer,"FOR4",4)!=0 || be32(hdr->size) < 8)
|
const unsigned int size=be32(hdr->size);
|
||||||
|
if(memcmp(buffer,"FOR4",4)!=0 || size < 8)
|
||||||
return 0;
|
return 0;
|
||||||
reset_file_recovery(file_recovery_new);
|
reset_file_recovery(file_recovery_new);
|
||||||
file_recovery_new->extension=file_hint_mb.extension;
|
file_recovery_new->extension=file_hint_mb.extension;
|
||||||
file_recovery_new->min_filesize=16;
|
file_recovery_new->min_filesize=16;
|
||||||
file_recovery_new->calculated_file_size=(uint64_t)be32(hdr->size)+8;
|
file_recovery_new->calculated_file_size=(uint64_t)size+8;
|
||||||
file_recovery_new->data_check=&data_check_size;
|
file_recovery_new->data_check=&data_check_size;
|
||||||
file_recovery_new->file_check=&file_check_size;
|
file_recovery_new->file_check=&file_check_size;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*@
|
||||||
|
@ requires buffer_size >= 4;
|
||||||
|
@ 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_mb, 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_mp(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_mp(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,"FOR4",4)!=0)
|
if(memcmp(buffer,"FOR4",4)!=0)
|
||||||
|
|
Loading…
Reference in a new issue