summaryrefslogtreecommitdiffstats
path: root/src/file_spf.c
diff options
context:
space:
mode:
authorChristophe Grenier <[email protected]>2020-10-12 17:40:49 +0200
committerChristophe Grenier <[email protected]>2020-10-12 17:40:49 +0200
commit619b831b5151236e6eec082db01e105052e86d76 (patch)
tree087e797be4d8df4a3593edbc627d4586c7e56fee /src/file_spf.c
parent2ee22935e791caadcc636b9ac466cf76c9ed161f (diff)
src/file_spf.c: fix frama-c warnings
Diffstat (limited to 'src/file_spf.c')
-rw-r--r--src/file_spf.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/file_spf.c b/src/file_spf.c
index f0df65c4..c5c67636 100644
--- a/src/file_spf.c
+++ b/src/file_spf.c
@@ -49,28 +49,35 @@ enum { READ_SIZE=32*512 };
static void file_check_spf(file_recovery_t *file_recovery)
{
unsigned char*buffer;
- buffer=(unsigned char*)MALLOC(READ_SIZE);
file_recovery->file_size=0;
if(my_fseek(file_recovery->handle, 0, SEEK_SET)<0)
{
- free(buffer);
return;
}
+ buffer=(unsigned char*)MALLOC(READ_SIZE);
while(1)
{
int i;
const int taille=fread(buffer,1,READ_SIZE,file_recovery->handle);
- if(taille<512)
+ if(taille<512 || taille%512!=0)
{
file_recovery->file_size=0;
free(buffer);
return ;
}
+#ifdef __FRAMAC__
+ Frama_C_make_unknown(buffer, READ_SIZE);
+#endif
for(i=0; i<taille; i+=512)
{
int j;
int is_valid=0;
file_recovery->file_size+=512;
+ if(file_recovery->file_size >= PHOTOREC_MAX_FILE_SIZE)
+ {
+ free(buffer);
+ return;
+ }
for(j=0; j<8; j++)
if(buffer[i+j]!=0)
is_valid=1;