summaryrefslogtreecommitdiffstats
path: root/src/file_it.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-03-23 14:50:48 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-03-23 14:50:48 +0100
commitde38e65c81317de733b7b893eafa2869e4c97ffb (patch)
tree6b4f3e2733629918acf6058801e26c0ce49c47bb /src/file_it.c
parentd1d77e56fdcec2252586b4d0c1d2e77ab35a73ee (diff)
PhotoRec: stricter check for Impulse audio .it file
Diffstat (limited to 'src/file_it.c')
-rw-r--r--src/file_it.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/file_it.c b/src/file_it.c
index 55dc681..1567893 100644
--- a/src/file_it.c
+++ b/src/file_it.c
@@ -31,7 +31,6 @@
#include "filegen.h"
static void register_header_check_it(file_stat_t *file_stat);
-static int header_check_it(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 file_hint_t file_hint_it= {
.extension="it",
@@ -43,21 +42,44 @@ const file_hint_t file_hint_it= {
.register_header_check=&register_header_check_it
};
-static const unsigned char it_header[4]= {
- 'I' , 'M' , 'P' , 'M' };
+/* http://schismtracker.org/wiki/ITTECH.TXT */
+struct impulse_header
+{
+ uint32_t magic;
+ char song_name[26];
+ uint16_t PHiligt;
+ uint16_t OrdNum;
+ uint16_t InsNum;
+ uint16_t SmpNum;
+ uint16_t PatNum;
+ uint16_t Cwtv;
+ uint16_t Cmwt;
+ uint16_t Flags;
+ uint16_t Special;
+ uint8_t GV;
+ uint8_t MV;
+ uint8_t IS;
+ uint8_t IT;
+ uint8_t Sep;
+ uint8_t PWD;
+ uint16_t MsgLgth;
+ uint16_t MsgOff;
+ uint32_t Reserved;
+ char Chnl_Pan[64];
+ char Chnl_Vol[64];
+} __attribute__ ((__packed__));
-static void register_header_check_it(file_stat_t *file_stat)
+static int header_check_it(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)
{
- register_header_check(0, it_header, sizeof(it_header), &header_check_it, file_stat);
+ const struct impulse_header *header=(const struct impulse_header *)buffer;
+ if(header->Reserved!=0)
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_it.extension;
+ return 1;
}
-static int header_check_it(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 void register_header_check_it(file_stat_t *file_stat)
{
- if(memcmp(&buffer[0], it_header, sizeof(it_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_it.extension;
- return 1;
- }
- return 0;
+ register_header_check(0, "IMPM", 4, &header_check_it, file_stat);
}