summaryrefslogtreecommitdiffstats
path: root/src/file_bac.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-03-10 15:58:06 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-03-10 15:58:06 +0100
commitb2d291cb0020b9b83a07509534a5b73acdb3ff37 (patch)
tree7c0eac6634bd36265883c75b74147890352bb432 /src/file_bac.c
parent72f23100a045f1c40f221b153b8e07d51e8012bf (diff)
PhotoRec: fix .bac recovery when blocksize=1
Diffstat (limited to 'src/file_bac.c')
-rw-r--r--src/file_bac.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/file_bac.c b/src/file_bac.c
index e7a6191..f20eeec 100644
--- a/src/file_bac.c
+++ b/src/file_bac.c
@@ -34,8 +34,6 @@
#include "memmem.h"
static void register_header_check_bac(file_stat_t *file_stat);
-static int header_check_bac(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 data_check_bac(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery);
const file_hint_t file_hint_bac= {
.extension="bac",
@@ -47,26 +45,6 @@ const file_hint_t file_hint_bac= {
.register_header_check=&register_header_check_bac
};
-static const unsigned char bac_header[8]={ 0, 0, 0, 0, 'B', 'B', '0', '2' };
-static void register_header_check_bac(file_stat_t *file_stat)
-{
- register_header_check(8, bac_header, sizeof(bac_header), &header_check_bac, file_stat);
-}
-
-static int header_check_bac(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[8], bac_header, sizeof(bac_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_bac.extension;
- file_recovery_new->data_check=data_check_bac;
- file_recovery_new->file_check=&file_check_size;
- file_recovery_new->calculated_file_size=0;
- return 1;
- }
- return 0;
-}
-
static int data_check_bac(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
{
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
@@ -95,3 +73,21 @@ static int data_check_bac(const unsigned char *buffer, const unsigned int buffer
return 1;
}
+static int header_check_bac(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)
+{
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_bac.extension;
+ file_recovery_new->calculated_file_size=0;
+ if(file_recovery_new->blocksize >= 0x18/2)
+ {
+ file_recovery_new->data_check=data_check_bac;
+ file_recovery_new->file_check=&file_check_size;
+ }
+ return 1;
+}
+
+static void register_header_check_bac(file_stat_t *file_stat)
+{
+ static const unsigned char bac_header[8]={ 0, 0, 0, 0, 'B', 'B', '0', '2' };
+ register_header_check(8, bac_header, sizeof(bac_header), &header_check_bac, file_stat);
+}