Skip to content

Commit 5473a29

Browse files
committed
src/file_sig.c: improve Frama-C annotation for load_signature()
1 parent 2327c1f commit 5473a29

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/file_sig.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,15 @@ static unsigned int load_hex2(const unsigned char c1, const unsigned char c2)
471471
}
472472

473473
/*@
474+
@ requires \valid(ptr);
474475
@ requires \valid(*ptr);
475476
@ requires valid_string(*ptr);
476477
@ requires \valid(tmp + (0 .. PHOTOREC_MAX_SIG_SIZE-1));
478+
@ requires \separated(ptr, tmp + (..));
477479
@ ensures valid_string(*ptr);
478480
@ ensures \initialized(tmp + (0 .. \result-1));
481+
@ assigns *ptr, tmp[0 .. PHOTOREC_MAX_SIG_SIZE-1];
479482
@*/
480-
/* TODO assigns *ptr, tmp[0 .. PHOTOREC_MAX_SIG_SIZE-1]; */
481483
static unsigned int load_signature(char **ptr, unsigned char *tmp)
482484
{
483485
unsigned int signature_size=0;
@@ -649,14 +651,14 @@ static char *parse_signature_line(file_stat_t *file_stat, char *pos)
649651
if(sig_size>0 && sig_offset + sig_size <= PHOTOREC_MAX_SIG_OFFSET )
650652
{
651653
/* FIXME: memory leak for signature */
652-
void *signature;
654+
char *signature;
653655
/*@ assert sig_size > 0; */
654656
/*@ assert sig_offset + sig_size <= PHOTOREC_MAX_SIG_OFFSET; */
655-
signature=(void *)MALLOC(sig_size);
656-
/*@ assert \valid((char *)signature + (0 .. sig_size - 1)); */
657+
signature=(char*)MALLOC(sig_size);
658+
/*@ assert \valid(signature + (0 .. sig_size - 1)); */
657659
memcpy(signature, sig_sig, sig_size);
658-
#ifndef DISABLED_FOR_FRAMAC
659660
signature_insert(sig_ext, sig_offset, signature, sig_size);
661+
#ifndef DISABLED_FOR_FRAMAC
660662
register_header_check(sig_offset, signature, sig_size, &header_check_sig, file_stat);
661663
#endif
662664
}

0 commit comments

Comments
 (0)