summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2020-08-24 18:50:51 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2020-08-24 18:51:29 +0200
commit28462586703df7507411b285174cd59b279bbd8d (patch)
treeb44cbd6bbf0e3c3d91abd7ad3cdc1a664c67d417
parentc475b596b3b8f598e729df72a2a92d63765b94ad (diff)
src/file_zip.c: Fix header_check_zip(), see commit d4a638cc44b6ec43d9b361d3ac4de56da25e1e16
src/filegen.c: remove unused file_search_lc_footer() src/file_doc.c: remove useless cast
-rw-r--r--src/file_doc.c2
-rw-r--r--src/file_zip.c2
-rw-r--r--src/filegen.c46
3 files changed, 2 insertions, 48 deletions
diff --git a/src/file_doc.c b/src/file_doc.c
index 6f287f9..88347b4 100644
--- a/src/file_doc.c
+++ b/src/file_doc.c
@@ -684,7 +684,7 @@ static uint32_t *OLE_load_MiniFAT(FILE *IN, const struct OLE_HDR *header, const
free(minifat);
return NULL;
}
- if(OLE_read_block(IN, (char *)minifat_pos, uSectorShift, block, offset)<0)
+ if(OLE_read_block(IN, minifat_pos, uSectorShift, block, offset)<0)
{
free(minifat);
return NULL;
diff --git a/src/file_zip.c b/src/file_zip.c
index 58feb98..6b806eb 100644
--- a/src/file_zip.c
+++ b/src/file_zip.c
@@ -1212,7 +1212,7 @@ static int header_check_zip(const unsigned char *buffer, const unsigned int buff
#endif
/* A zip file begins by ZIP_FILE_ENTRY, this signature can also be
* found for each compressed file */
- if(file_recovery->file_check == file_check_zip &&
+ if(file_recovery->file_check == &file_check_zip &&
file_recovery->file_stat!=NULL &&
// file_recovery->file_stat->file_hint==&file_hint_zip &&
safe_header_only==0)
diff --git a/src/filegen.c b/src/filegen.c
index d8eec1a..67d4edb 100644
--- a/src/filegen.c
+++ b/src/filegen.c
@@ -325,52 +325,6 @@ void file_search_footer(file_recovery_t *file_recovery, const void*footer, const
/*@ assert \valid(file_recovery->handle); */
}
-/*@
- @ requires \valid(file_recovery);
- @ requires footer_length > 0;
- @ requires \valid_read((char *)footer+(0..footer_length-1));
- @*/
-static void file_search_lc_footer(file_recovery_t *file_recovery, const unsigned char*footer, const unsigned int footer_length)
-{
- const unsigned int read_size=4096;
- unsigned char*buffer;
- int64_t file_size;
- if(footer_length==0)
- return ;
- buffer=(unsigned char*)MALLOC(read_size+footer_length-1);
- file_size=file_recovery->file_size;
- memset(buffer+read_size,0,footer_length-1);
- do
- {
- int i;
- int taille;
- if(file_size%read_size!=0)
- file_size=file_size-(file_size%read_size);
- else
- file_size-=read_size;
- if(my_fseek(file_recovery->handle,file_size,SEEK_SET)<0)
- {
- free(buffer);
- return;
- }
- taille=fread(buffer,1,read_size,file_recovery->handle);
- for(i=0;i<taille;i++)
- buffer[i]=tolower(buffer[i]);
- for(i=taille-1;i>=0;i--)
- {
- if(buffer[i]==footer[0] && memcmp(buffer+i,footer,footer_length)==0)
- {
- file_recovery->file_size=file_size+i+footer_length;
- free(buffer);
- return;
- }
- }
- memcpy(buffer+read_size,buffer,footer_length-1);
- } while(file_size>0);
- file_recovery->file_size=0;
- free(buffer);
-}
-
data_check_t data_check_size(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
{
if(file_recovery->file_size + buffer_size/2 >= file_recovery->calculated_file_size)