summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-01-14 23:48:51 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2008-01-14 23:48:51 +0100
commit9a9764e493c4d016343c050d099af4bdbdc58862 (patch)
tree88ba3d3282e2d20710fa6499774315aa6da9655c
parent3c8e7a507ab58a485b677a1bf58aa6968267fe77 (diff)
PhotoRec: expert can stop pass 0 and set the blocksize
-rw-r--r--linux/testdisk.spec.in2
-rw-r--r--src/adv.c2
-rw-r--r--src/ext2.c2
-rw-r--r--src/fat_dir.c2
-rw-r--r--src/file_pst.c41
-rw-r--r--src/geometry.c4
-rw-r--r--src/memmem.h2
-rw-r--r--src/ntfs_fix.c40
-rw-r--r--src/phrecn.c42
9 files changed, 84 insertions, 53 deletions
diff --git a/linux/testdisk.spec.in b/linux/testdisk.spec.in
index 85ffd2f..bebb311 100644
--- a/linux/testdisk.spec.in
+++ b/linux/testdisk.spec.in
@@ -1,5 +1,5 @@
%define ver_progsreiserfs 0.3.1-rc8
-%define ver_ntfsprogs 1.13.1
+%define ver_ntfsprogs 2.0.0
Summary: Tool to check and undelete partition
Summary(pl.UTF8): Narzędzie sprawdzające i odzyskujące partycje
diff --git a/src/adv.c b/src/adv.c
index c395fca..2f2cf4d 100644
--- a/src/adv.c
+++ b/src/adv.c
@@ -767,7 +767,7 @@ int fat32_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
{
menu=4;
options="DORL";
- }
+ }
}
else
{
diff --git a/src/ext2.c b/src/ext2.c
index 37a5195..0f597ff 100644
--- a/src/ext2.c
+++ b/src/ext2.c
@@ -161,7 +161,7 @@ static int test_EXT2(disk_t *disk_car, const struct ext2_super_block *sb,partiti
(le16(sb->s_errors) != EXT2_ERRORS_CONTINUE) &&
(le16(sb->s_errors) != EXT2_ERRORS_RO) &&
(le16(sb->s_errors) != EXT2_ERRORS_PANIC))
- return 5;
+ return 4;
if ((le16(sb->s_state) & ~(EXT2_VALID_FS | EXT2_ERROR_FS))!=0)
return 5;
if (le32(sb->s_blocks_count) == 0) /* reject empty filesystem */
diff --git a/src/fat_dir.c b/src/fat_dir.c
index 3501d2e..bd74e4f 100644
--- a/src/fat_dir.c
+++ b/src/fat_dir.c
@@ -254,7 +254,7 @@ static file_data_t *fat12_dir(disk_t *disk_car, const partition_t *partition, di
memset(buffer_dir,0,fat_sector_size(fat_header)*cluster_size*10);
for(cluster=first_cluster, nbr_cluster=0;
((cluster&0x0ff8)!=(unsigned)FAT12_EOC) && (cluster>=2) && (nbr_cluster<10) && (stop==0);
- cluster=get_next_cluster(disk_car,partition, UP_FAT12,le16(fat_header->reserved), cluster), nbr_cluster++)
+ cluster=get_next_cluster(disk_car, partition, UP_FAT12, le16(fat_header->reserved), cluster), nbr_cluster++)
{
uint64_t start=partition->part_offset+(uint64_t)(le16(fat_header->reserved)+fat_header->fats*le16(fat_header->fat_length)+(get_dir_entries(fat_header)*32+fat_sector_size(fat_header)-1)/fat_sector_size(fat_header)+(uint64_t)(cluster-2)*cluster_size)*fat_sector_size(fat_header);
if(dir_data->verbose>0)
diff --git a/src/file_pst.c b/src/file_pst.c
index c97b64e..58c516c 100644
--- a/src/file_pst.c
+++ b/src/file_pst.c
@@ -58,6 +58,30 @@ static void register_header_check_pst(file_stat_t *file_stat)
#define INDEX_TYPE_OFFSET 0x0A
#define FILE_SIZE_POINTER 0xA8
#define FILE_SIZE_POINTER_64 0xB8
+/*
+ Outlook 2000
+ 0x0000 uchar signature[4];
+ 0x000a uchar indexType;
+ 0x00a8 uint32_t total_file_size;
+ 0x00b8 uint32_t backPointer2;
+ 0x00bc uint32_t offsetIndex2;
+ 0x00c0 uint32_t backPointer1;
+ 0x00c4 uint32_t offsetIndex1;
+ 0x01cd uchar encryptionType;
+
+ Outlook 2003
+ 0x0000 uchar signature[4];
+ 0x000a uchar indexType;
+ 0x00b8 uint64_t total_file_size;
+ 0x00d8 uint64_t backPointer2;
+ 0x00e0 uint64_t offsetIndex2;
+ 0x00e8 uint64_t backPointer1;
+ 0x00f0 uint64_t offsetIndex1;
+ 0x0201 uchar encryptionType;
+
+ More information about the file structure can be found at
+ http://www.five-ten-sg.com/libpst/
+*/
static int header_check_pst(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)
{
@@ -75,18 +99,23 @@ static int header_check_pst(const unsigned char *buffer, const unsigned int buff
}
if(memcmp(buffer,pst_header,sizeof(pst_header))==0)
{
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_pst.extension;
if(buffer[INDEX_TYPE_OFFSET]==0x0e)
{
/* Outlook 2000 and older versions */
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_pst.extension;
file_recovery_new->calculated_file_size=(uint64_t)buffer[FILE_SIZE_POINTER] +
(((uint64_t)buffer[FILE_SIZE_POINTER+1])<<8) +
(((uint64_t)buffer[FILE_SIZE_POINTER+2])<<16) +
(((uint64_t)buffer[FILE_SIZE_POINTER+3])<<24);
+ file_recovery_new->data_check=&data_check_size;
+ file_recovery_new->file_check=&file_check_size;
+ return 1;
}
- else
+ else if(buffer[INDEX_TYPE_OFFSET]==0x17)
{ /* Outlook 2003 */
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_pst.extension;
file_recovery_new->calculated_file_size=(uint64_t)buffer[FILE_SIZE_POINTER_64] +
(((uint64_t)buffer[FILE_SIZE_POINTER_64+1])<<8) +
(((uint64_t)buffer[FILE_SIZE_POINTER_64+2])<<16) +
@@ -95,10 +124,10 @@ static int header_check_pst(const unsigned char *buffer, const unsigned int buff
(((uint64_t)buffer[FILE_SIZE_POINTER_64+5])<<40) +
(((uint64_t)buffer[FILE_SIZE_POINTER_64+6])<<48) +
(((uint64_t)buffer[FILE_SIZE_POINTER_64+7])<<56);
+ file_recovery_new->data_check=&data_check_size;
+ file_recovery_new->file_check=&file_check_size;
+ return 1;
}
- file_recovery_new->data_check=&data_check_size;
- file_recovery_new->file_check=&file_check_size;
- return 1;
}
return 0;
}
diff --git a/src/geometry.c b/src/geometry.c
index 64420f2..afd8a77 100644
--- a/src/geometry.c
+++ b/src/geometry.c
@@ -233,7 +233,7 @@ static void change_geometry_ncurses(disk_t *disk_car)
if(cyl_modified==0)
{ /* Round up */
disk_car->CHS.cylinder=(((disk_car->disk_size/disk_car->sector_size+disk_car->CHS.head)/(disk_car->CHS.head+1))+disk_car->CHS.sector-1)/disk_car->CHS.sector-1;
- }
+ }
} else
wprintw(stdscr,"Illegal sectors value");
}
@@ -254,7 +254,7 @@ static void change_geometry_ncurses(disk_t *disk_car)
if(cyl_modified==0)
{ /* Round up */
disk_car->CHS.cylinder=(((disk_car->disk_size/disk_car->sector_size+disk_car->CHS.head)/(disk_car->CHS.head+1))+disk_car->CHS.sector-1)/disk_car->CHS.sector-1;
- }
+ }
} else
wprintw(stdscr,"Illegal sector size");
}
diff --git a/src/memmem.h b/src/memmem.h
index 8a700f1..d738dba 100644
--- a/src/memmem.h
+++ b/src/memmem.h
@@ -35,7 +35,7 @@ static inline const void *td_memmem(const void *haystack, const unsigned int hay
/* Sanity check, otherwise the loop might search through the whole
memory. */
if (haystack_len < needle_len)
- return NULL;
+ return NULL;
for (begin = (const char *) haystack; begin <= last_possible; ++begin)
if (begin[0] == ((const char *) needle)[0] &&
diff --git a/src/ntfs_fix.c b/src/ntfs_fix.c
index 9e61391..e2b26d0 100644
--- a/src/ntfs_fix.c
+++ b/src/ntfs_fix.c
@@ -205,21 +205,21 @@ int repair_MFT(disk_t *disk_car, partition_t *partition, const int verbose, cons
log_info("Don't fix MFT mirror.\n");
}
else if(res1<res2)
- {
+ {
/* Use MFT mirror */
if(ask_confirmation("Fix MFT ? (Y/N)")!=0)
use_MFT=2;
else
log_info("Don't fix MFT.\n");
- }
- else
+ }
+ else
{ /* res1==res2 */
if(res1<0)
log_error("MFT and MFT mirror are bad. Failed to repair them.\n");
else
log_error("Both MFT seems ok but they don't match, use chkdsk.\n");
if(expert==0)
- {
+ {
if(res1<0)
display_message("MFT and MFT mirror are bad. Failed to repair them.\n");
else
@@ -264,27 +264,27 @@ int repair_MFT(disk_t *disk_car, partition_t *partition, const int verbose, cons
default:
use_MFT=0;
break;
- }
+ }
#endif
- }
+ }
}
}
if(use_MFT==2)
- {
- if(disk_car->write(disk_car, mftmirr_size_bytes, buffer_mftmirr, mft_pos)!=0)
- {
- log_error("Failed to fix MFT: write error.\n");
- display_message("Failed to fix MFT: write error.\n");
- }
- else
- {
- disk_car->sync(disk_car);
- log_info("MFT fixed.\n");
- display_message("MFT fixed.\n");
- }
- }
+ {
+ if(disk_car->write(disk_car, mftmirr_size_bytes, buffer_mftmirr, mft_pos)!=0)
+ {
+ log_error("Failed to fix MFT: write error.\n");
+ display_message("Failed to fix MFT: write error.\n");
+ }
+ else
+ {
+ disk_car->sync(disk_car);
+ log_info("MFT fixed.\n");
+ display_message("MFT fixed.\n");
+ }
+ }
else if(use_MFT==1)
- {
+ {
if(disk_car->write(disk_car, mftmirr_size_bytes, buffer_mft, mftmirr_pos)!=0)
{
log_error("Failed to fix MFT mirror: write error.\n");
diff --git a/src/phrecn.c b/src/phrecn.c
index 5fb99df..d4852be 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -1102,6 +1102,8 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb
#endif
update_blocksize(*blocksize,list_search_space, start_offset);
free_list_search_space(&list_file);
+ /* An expert can stop and manually set the blocksize without stopping the recovery */
+ ind_stop=0;
}
free(buffer_start);
#ifdef HAVE_NCURSES
@@ -2157,36 +2159,36 @@ static void interface_file_select(file_enable_t *files_enable, char**current_cmd
else
{
unsigned int cmd_length=0;
- while((*current_cmd)[cmd_length]!='\0' && (*current_cmd)[cmd_length]!=',')
- cmd_length++;
+ while((*current_cmd)[cmd_length]!='\0' && (*current_cmd)[cmd_length]!=',')
+ cmd_length++;
for(file_enable=&files_enable[0];file_enable->file_hint!=NULL;file_enable++)
- {
+ {
if(file_enable->file_hint->extension!=NULL &&
strlen(file_enable->file_hint->extension)==cmd_length &&
memcmp(file_enable->file_hint->extension,*current_cmd,cmd_length)==0)
- {
- keep_asking=1;
- (*current_cmd)+=cmd_length;
- while(*current_cmd[0]==',')
- (*current_cmd)++;
- if(strncmp(*current_cmd,"enable",6)==0)
{
- (*current_cmd)+=6;
+ keep_asking=1;
+ (*current_cmd)+=cmd_length;
+ while(*current_cmd[0]==',')
+ (*current_cmd)++;
+ if(strncmp(*current_cmd,"enable",6)==0)
+ {
+ (*current_cmd)+=6;
file_enable->enable=1;
- }
- else if(strncmp(*current_cmd,"disable",7)==0)
- {
- (*current_cmd)+=7;
+ }
+ else if(strncmp(*current_cmd,"disable",7)==0)
+ {
+ (*current_cmd)+=7;
file_enable->enable=0;
- }
- else
- {
- log_critical("Syntax error %s\n",*current_cmd);
- return;
+ }
+ else
+ {
+ log_critical("Syntax error %s\n",*current_cmd);
+ return;
+ }
}
}
}
- }
} while(keep_asking>0);
return;
}