PhotoRec: fix Windows 9x .reg bound checking

This commit is contained in:
Christophe Grenier 2013-10-20 12:30:04 +02:00
parent 9398e8ab2c
commit d260e01574

View file

@ -73,15 +73,17 @@ struct rgdb_block
static int header_check_reg_9x(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new) static int header_check_reg_9x(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{ {
const struct creg_file_header*header=(const struct creg_file_header*)buffer; const struct creg_file_header*header=(const struct creg_file_header*)buffer;
const struct rgdb_block*block=(const struct rgdb_block*)buffer+le32(header->rgdb_offset);
if(le32(header->rgdb_offset)+4 > buffer_size) if(le32(header->rgdb_offset)+4 > buffer_size)
return 0; return 0;
if(memcmp(block,"RGDB",4)!=0) {
return 0; const struct rgdb_block*block=(const struct rgdb_block*)(buffer+le32(header->rgdb_offset));
reset_file_recovery(file_recovery_new); if(memcmp(block,"RGDB",4)!=0)
file_recovery_new->min_filesize=0x1000; return 0;
file_recovery_new->extension=file_hint_reg.extension; reset_file_recovery(file_recovery_new);
return 1; file_recovery_new->min_filesize=0x1000;
file_recovery_new->extension=file_hint_reg.extension;
return 1;
}
} }
struct regf_file_header struct regf_file_header