summaryrefslogtreecommitdiffstats
path: root/src/file_ape.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-07-03 07:35:51 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2009-07-03 07:35:51 +0200
commit7b9693d6eaa8fb130e17e512603eb12dfed8af13 (patch)
tree51cc8212bc1905ec802124d5309e3ce399bf3bcc /src/file_ape.c
parentdb0885a2287e101836d96b4753d23c0407fe37a5 (diff)
PhotoRec: stricter check for .ape, Monkey's Audio compressed format
Diffstat (limited to 'src/file_ape.c')
-rw-r--r--src/file_ape.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/file_ape.c b/src/file_ape.c
index a7fe917..121b381 100644
--- a/src/file_ape.c
+++ b/src/file_ape.c
@@ -28,7 +28,7 @@
#include <stdio.h>
#include "types.h"
#include "filegen.h"
-
+#include "common.h"
static void register_header_check_ape(file_stat_t *file_stat);
static int header_check_ape(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);
@@ -50,9 +50,18 @@ static void register_header_check_ape(file_stat_t *file_stat)
register_header_check(0, ape_header,sizeof(ape_header), &header_check_ape, file_stat);
}
+struct APE_COMMON_HEADER
+{
+ char cID[4]; /* should equal 'MAC ' */
+ uint16_t nVersion; /* version number * 1000 (3.81 = 3810) */
+};
+
static int header_check_ape(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,ape_header,sizeof(ape_header))==0)
+ const struct APE_COMMON_HEADER *ape=(const struct APE_COMMON_HEADER*)buffer;
+ /* Version 3.96 released April 7, 2002, Version 4.06 March 17, 2009 */
+ if(memcmp(buffer,ape_header,sizeof(ape_header))==0 &&
+ le16(ape->nVersion)>3000 && le16(ape->nVersion)<6000)
{
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_ape.extension;