diff --git a/src/file_frm.c b/src/file_frm.c index a861fd91..826bd8dc 100644 --- a/src/file_frm.c +++ b/src/file_frm.c @@ -45,27 +45,6 @@ const file_hint_t file_hint_frm= { .register_header_check=®ister_header_check_frm }; -static const unsigned char frm_header[14]= { - '#', 'U', 'G', 'C', ':', '2', ' ', 'D', - 'W', 'G', 'F', 'O', 'R', 'M'}; - -static void register_header_check_frm(file_stat_t *file_stat) -{ - register_header_check(0, frm_header,sizeof(frm_header), &header_check_frm, file_stat); -} - -static int header_check_frm(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) -{ - if(memcmp(buffer,frm_header,sizeof(frm_header))==0) - { - reset_file_recovery(file_recovery_new); - file_recovery_new->file_check=file_check_frm; - file_recovery_new->extension=file_hint_frm.extension; - return 1; - } - return 0; -} - static void file_check_frm(file_recovery_t *file_recovery) { const unsigned char frm_footer[11]= { @@ -73,3 +52,21 @@ static void file_check_frm(file_recovery_t *file_recovery) 'U', 'G', 'C'}; file_search_footer(file_recovery, frm_footer, sizeof(frm_footer), 1); } + +static int header_check_frm(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) +{ + if(!isprint(buffer[14]) || !isprint(buffer[15]) || !isprint(buffer[16]) || !isprint(buffer[17])) + return 0; + reset_file_recovery(file_recovery_new); + file_recovery_new->file_check=file_check_frm; + file_recovery_new->extension=file_hint_frm.extension; + return 1; +} + +static void register_header_check_frm(file_stat_t *file_stat) +{ + static const unsigned char frm_header[14]= { + '#', 'U', 'G', 'C', ':', '2', ' ', 'D', + 'W', 'G', 'F', 'O', 'R', 'M'}; + register_header_check(0, frm_header,sizeof(frm_header), &header_check_frm, file_stat); +}