src/file_zip.c: Fix header_check_zip(), see commit d4a638cc44

src/filegen.c: remove unused file_search_lc_footer()
src/file_doc.c: remove useless cast
This commit is contained in:
Christophe Grenier 2020-08-24 18:50:51 +02:00
parent c475b596b3
commit 2846258670
3 changed files with 2 additions and 48 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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)