cgsecurity / testdisk

TestDisk & PhotoRec
https://www.cgsecurity.org/
GNU General Public License v2.0
1.58k stars 195 forks source link

Add RAR 5 signature #43

Closed alexbrownbear closed 6 years ago

alexbrownbear commented 6 years ago

Thanks for your work! Your program has very much helped me

cgsecurity commented 6 years ago

In register_header_check_rar(), can you avoid mixing variable declaration and code ? The minimum filesize seems to be 60, not 70.

cgsecurity commented 6 years ago

Sorry if I have not been clear. Instead of

 static const unsigned char rar_header[7]={0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
 register_header_check(0, rar_header,sizeof(rar_header), &header_check_rar, file_stat);
 static const unsigned char rar5_header[8]={0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 }; //RAR5 header
 register_header_check(0, rar5_header,sizeof(rar5_header), &header_check_rar5, file_stat);

I prefer

 static const unsigned char rar_header[7]={0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
 static const unsigned char rar5_header[8]={0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 }; //RAR5 header
 register_header_check(0, rar_header,sizeof(rar_header), &header_check_rar, file_stat);
 register_header_check(0, rar5_header,sizeof(rar5_header), &header_check_rar5, file_stat);

Didn't you see the warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] ?

In the last version, the two header signatures are identical! You have introduced new bugs...

alexbrownbear commented 6 years ago

Oops, sorry for a bug. I didn't know that this commit added to pull request automatic =) I did trying imitate style like in another extensions and format naming from unrar lib. I build it on windows and have a lot of warnings =( Now I successfully tested it on two different rar files.