PhotoRec: use memcmp() instead of strcmp() when parsing exe and tiff files

This commit is contained in:
Christophe Grenier 2018-02-18 10:46:53 +01:00
parent fe2059efa9
commit d13e22df20
3 changed files with 6 additions and 6 deletions

View file

@ -503,7 +503,7 @@ static void file_rename_pe_exe(file_recovery_t *file_recovery)
{
if(le32(pe_section->SizeOfRawData)>0)
{
if(strcmp((const char*)pe_section->Name, ".rsrc")==0)
if(memcmp((const char*)pe_section->Name, ".rsrc", 6)==0)
{
file_exe_ressource(file,
le32(pe_section->PointerToRawData),

View file

@ -499,12 +499,12 @@ int header_check_tiff_be_new(const unsigned char *buffer, const unsigned int buf
tag_make=find_tag_from_tiff_header_be(header, buffer_size, TIFFTAG_MAKE, &potential_error);
if(tag_make!=NULL && tag_make >= (const char *)buffer && tag_make < (const char *)buffer + buffer_size - 20)
{
if(strcmp(tag_make, "PENTAX Corporation ")==0 ||
strcmp(tag_make, "PENTAX ")==0)
if( memcmp(tag_make, "PENTAX Corporation ", 20)==0 ||
memcmp(tag_make, "PENTAX ", 20)==0)
file_recovery_new->extension="pef";
else if(strcmp(tag_make, "NIKON CORPORATION")==0)
else if(memcmp(tag_make, "NIKON CORPORATION", 18)==0)
file_recovery_new->extension="nef";
else if(strcmp(tag_make, "Kodak")==0)
else if(memcmp(tag_make, "Kodak", 6)==0)
file_recovery_new->extension="dcr";
}
}

View file

@ -522,7 +522,7 @@ int header_check_tiff_le_new(const unsigned char *buffer, const unsigned int buf
/* TODO
* sr2 if Sony::FileFormat begins by 1
* arw otherwise */
if(strcmp(tag_make, "SONY")==0)
if(memcmp(tag_make, "SONY", 5)==0)
file_recovery_new->extension="sr2";
else if(strncmp(tag_make, "SONY ",5)==0)
file_recovery_new->extension="arw";