summaryrefslogtreecommitdiffstats
path: root/src/parti386.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-01-11 10:55:59 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2014-01-11 10:55:59 +0100
commit692be3bf8ef6cc343d3552670c8a4e9b01779686 (patch)
tree8b07f606743fbec75aa79daf65806aaee0678903 /src/parti386.c
parentfd53b5603c81115a42e5b27e9aa0ab21ff2687b0 (diff)
TestDisk: when deleting PC/Intel partition list, remove Mac, Sun and XBOX signature if present.
Diffstat (limited to 'src/parti386.c')
-rw-r--r--src/parti386.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/parti386.c b/src/parti386.c
index 1a09583..eb410f7 100644
--- a/src/parti386.c
+++ b/src/parti386.c
@@ -56,6 +56,7 @@
#include "log.h"
#include "parti386.h"
#include "partgpt.h"
+#include "partxbox.h"
#define TAB_PART 0x1BE
static int is_extended(const unsigned int part_type);
@@ -889,7 +890,7 @@ static int diff(const unsigned char buffer[DEFAULT_SECTOR_SIZE], const unsigned
{
if(memcmp(buffer,buffer_org,DEFAULT_SECTOR_SIZE))
{
- int j;
+ unsigned int j;
log_info("\nSectors are different.\n");
log_info("buffer_org\n");
for(j=0;j<4;j++)
@@ -1480,11 +1481,30 @@ static int erase_list_part_i386(disk_t *disk)
memset(buffer,0,sizeof(buffer));
}
memset(buffer+TAB_PART,0,0x40);
+ /* Remove Mac signature */
+ if(buffer[0]==0x45 && buffer[1]==0x52)
+ buffer[0]=0;
+ /* Remove Sun signature */
+ if(buffer[0x1fc]==0xda && buffer[0x1fd]==0xbe)
+ buffer[0x1fc]=0;
if(disk->pwrite(disk, buffer, DEFAULT_SECTOR_SIZE, (uint64_t)0) != DEFAULT_SECTOR_SIZE)
{
return 1;
}
{
+ /* Erase XBOX signature if present */
+ struct xbox_partition *xboxlabel=(struct xbox_partition*)MALLOC(0x800);
+ if((unsigned)disk->pread(disk, xboxlabel, 0x800, 0) == 0x800)
+ {
+ if (memcmp(xboxlabel->magic,"BRFR",4)==0)
+ {
+ memset(xboxlabel->magic, 0, 4);
+ disk->pwrite(disk, xboxlabel, 0x800, 0);
+ }
+ }
+ free(xboxlabel);
+ }
+ {
/* Erase EFI GPT signature if present */
struct gpt_hdr *gpt=(struct gpt_hdr*)MALLOC(disk->sector_size);
if((unsigned)disk->pread(disk, gpt, disk->sector_size, disk->sector_size) == disk->sector_size)