Skip to content

Commit

Permalink
Prevent infinite loop with certain SD formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
d0k3 committed Jun 6, 2016
1 parent 051203e commit 7003070
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 2 additions & 0 deletions source/decryptor/nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ u32 CheckEmuNand(void)

// check the MBR for presence of a hidden partition
u32 hidden_sectors = NumHiddenSectors();
if (hidden_sectors > 4 * multi_sectors)
hidden_sectors = 4 * multi_sectors;

for (u32 offset_sector = 0; offset_sector + nand_size_sectors_min <= hidden_sectors; offset_sector += multi_sectors) {
// check for RedNAND type EmuNAND
Expand Down
4 changes: 0 additions & 4 deletions source/decryptor/nand.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#define P_FIRM1 (1<<4)
#define P_CTRNAND (1<<5)

// force slot 0x04 for CTRNAND padgen
#define PG_FORCESLOT4 (1<<0)

// options for NAND backup & restore
#define NB_MINSIZE (1<<10)
#define NR_NOCHECKS (1<<11)
Expand Down Expand Up @@ -53,7 +50,6 @@ u32 InputFileNameSelector(char* filename, const char* basename, char* extension,

u32 DecryptNandToMem(u8* buffer, u32 offset, u32 size, PartitionInfo* partition);
u32 DecryptNandToFile(const char* filename, u32 offset, u32 size, PartitionInfo* partition);
u32 DecryptNandToHash(u8* hash, u32 offset, u32 size, PartitionInfo* partition);
u32 EncryptMemToNand(u8* buffer, u32 offset, u32 size, PartitionInfo* partition);
u32 EncryptFileToNand(const char* filename, u32 offset, u32 size, PartitionInfo* partition);

Expand Down
2 changes: 1 addition & 1 deletion source/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,5 @@ uint64_t TotalStorageSpace()

uint32_t NumHiddenSectors()
{
return (uint32_t) fs.volbase - 1;
return (fs.volbase > 0) ? (uint32_t) fs.volbase - 1 : 0;
}

0 comments on commit 7003070

Please sign in to comment.