src/file_amr.c: fix frama-c warning in data_check_amr()
This commit is contained in:
parent
5ab05b0da3
commit
f347988c54
1 changed files with 15 additions and 6 deletions
|
@ -32,8 +32,8 @@
|
|||
#include "filegen.h"
|
||||
#include "log.h"
|
||||
|
||||
/*@ requires \valid(file_stat); */
|
||||
static void register_header_check_amr(file_stat_t *file_stat);
|
||||
static int header_check_amr(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_amr= {
|
||||
.extension="amr",
|
||||
|
@ -50,6 +50,7 @@ const file_hint_t file_hint_amr= {
|
|||
@ requires \valid_read(buffer+(0..buffer_size-1));
|
||||
@ requires \valid(file_recovery);
|
||||
@ requires file_recovery->data_check==&data_check_amr;
|
||||
@ 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;
|
||||
|
@ -62,7 +63,8 @@ static data_check_t data_check_amr(const unsigned char *buffer, const unsigned i
|
|||
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
|
||||
file_recovery->calculated_file_size + 4 < 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 - 4; */
|
||||
#ifdef DEBUG_AMR
|
||||
log_info("data_check_amr %04x %02x %u\n", file_recovery->calculated_file_size, buffer[i], (buffer[i]>>1)&7);
|
||||
#endif
|
||||
|
@ -85,6 +87,16 @@ static data_check_t data_check_amr(const unsigned char *buffer, const unsigned i
|
|||
return DC_CONTINUE;
|
||||
}
|
||||
|
||||
/*@
|
||||
@ requires buffer_size >= 10;
|
||||
@ 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_amr, buffer+(..), file_recovery, file_recovery_new);
|
||||
@ assigns *file_recovery_new;
|
||||
@ ensures \result!=0 ==> valid_file_recovery(file_recovery_new);
|
||||
@*/
|
||||
static int header_check_amr(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[6]&0x83)!=0)
|
||||
|
@ -99,10 +111,7 @@ static int header_check_amr(const unsigned char *buffer, const unsigned int buff
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* AMR file format is described in
|
||||
* http://developer.nokia.com/community/wiki/AMR_format
|
||||
* ftp://ftp.rfc-editor.org/in-notes/rfc3267.txt */
|
||||
|
||||
/* AMR file format is described in https://tools.ietf.org/html/rfc3267 */
|
||||
static void register_header_check_amr(file_stat_t *file_stat)
|
||||
{
|
||||
static const unsigned char amr_header[6]= {'#','!','A','M','R','\n'};
|
||||
|
|
Loading…
Reference in a new issue