Fix some of the bugs

This commit is contained in:
TuxSH
2018-05-26 12:25:24 +02:00
parent a65f7fbf88
commit f3b2a6c30d
7 changed files with 7 additions and 33 deletions

View File

@@ -36,6 +36,7 @@
#include "emunand.h"
#include "utils.h"
#include "alignedseqmemcpy.h"
#include "strings.h"
#include "fatfs/sdmmc/sdmmc.h"
/****************************************************************
@@ -581,9 +582,7 @@ void kernel9Loader(Arm9Bin *arm9Section)
u8 arm9BinSlot = k9lVersion == 0 ? 0x15 : 0x16;
// Get size
u32 arm9SectionSize = 0;
for(u32 i = 0; i < 8; i++)
arm9SectionSize = (arm9Section->size[i] - '0') + 10*arm9SectionSize;
u32 arm9SectionSize = decAtoi(arm9Section->size, 8);
//Set keyX
__attribute__((aligned(4))) u8 keyX[AES_BLOCK_SIZE];

View File

@@ -36,6 +36,7 @@
#include "buttons.h"
#include "firm.h"
#include "crypto.h"
#include "strings.h"
static FATFS sdFs,
nandFs;
@@ -272,10 +273,7 @@ u32 firmRead(void *dest, u32 firmType)
//Not a cxi
if(info.fname[9] != 'a' || strlen(info.fname) != 12) continue;
u32 tempVersion = 0;
char *tmp = info.fname;
for(u32 i = 0; i < 8 && *tmp != 0; tmp++, i++)
tempVersion = (*tmp > '9' ? (*tmp >= 'A' ? *tmp - 'A' : *tmp - 'a') + 10 : *tmp - '0') + (tempVersion << 4);
u32 tempVersion = hexAtoi(info.altname, 8);
//Found an older cxi
if(tempVersion < firmVersion) firmVersion = tempVersion;

View File

@@ -25,25 +25,6 @@
*/
#include "strings.h"
#include "memory.h"
u32 strlen(const char *string)
{
char *stringEnd = (char *)string;
while(*stringEnd != 0) stringEnd++;
return stringEnd - string;
}
u32 strnlen(const char *string, u32 maxlen)
{
u32 size;
for(size = 0; size < maxlen && *string; string++, size++);
return size;
}
u32 hexAtoi(const char *in, u32 digits)
{

View File

@@ -28,7 +28,5 @@
#include "types.h"
u32 strlen(const char *string);
u32 strnlen(const char *string, u32 maxlen);
u32 hexAtoi(const char *in, u32 digits);
u32 decAtoi(const char *in, u32 digits);