From f89845257e278aee167ab797492afbf2a2d21a45 Mon Sep 17 00:00:00 2001 From: Aurora Date: Sun, 11 Dec 2016 20:10:51 +0100 Subject: [PATCH] Minor stuff --- haxloader/diffs/1.diff | 2 +- haxloader/source/main.c | 2 +- source/patches.c | 15 +++++++-------- source/pin.c | 14 +++++--------- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/haxloader/diffs/1.diff b/haxloader/diffs/1.diff index 33b144d..196b216 100644 --- a/haxloader/diffs/1.diff +++ b/haxloader/diffs/1.diff @@ -50,7 +50,7 @@ diff -uNr a/source/brahma.c b/source/brahma.c + fseek(p , 0, SEEK_END); + psize = ftell(p); + if (psize > 5 && psize < 58) { -+ char path[58]; ++ char path[57]; + + fseek(p, 0, SEEK_SET); + u32 bytes_read = fread(path, 1, psize, p); diff --git a/haxloader/source/main.c b/haxloader/source/main.c index 39536fa..8680003 100644 --- a/haxloader/source/main.c +++ b/haxloader/source/main.c @@ -43,7 +43,7 @@ void main(void) if(pathSize > 5 && pathSize < 58) { - char path[58]; + char path[57]; unsigned int read; f_read(&pathFile, path, pathSize, &read); if(path[pathSize - 1] == 0xA) pathSize--; diff --git a/source/patches.c b/source/patches.c index 1655437..91f2542 100644 --- a/source/patches.c +++ b/source/patches.c @@ -38,19 +38,18 @@ static inline void pathChanger(u8 *pos) { const char *pathFile = "path.txt"; - - u32 pathSize = getFileSize(pathFile); - - if(pathSize < 6 || pathSize > 57) return; - u8 path[57]; - fileRead(path, pathFile, pathSize); + + u32 pathSize = fileRead(path, pathFile, sizeof(path)); + + if(pathSize < 6) return; + if(path[pathSize - 1] == 0xA) pathSize--; if(path[pathSize - 1] == 0xD) pathSize--; - if(pathSize < 6 || pathSize > 57 || path[0] != '/' || memcmp(path + pathSize - 4, ".bin", 4) != 0) return; + if(pathSize < 6 || pathSize > 55 || path[0] != '/' || memcmp(path + pathSize - 4, ".bin", 4) != 0) return; - u16 finalPath[58]; + u16 finalPath[56]; for(u32 i = 0; i < pathSize; i++) finalPath[i] = (u16)path[i]; diff --git a/source/pin.c b/source/pin.c index 502a6b3..9426661 100644 --- a/source/pin.c +++ b/source/pin.c @@ -150,18 +150,14 @@ bool verifyPin(u32 pinMode) drawCharacter('0' + lengthBlock[0], true, 10 + 5 * SPACING_X, 10 + 3 * SPACING_Y, COLOR_WHITE); const char *messageFile = "pinmessage.txt"; + char message[801]; - u32 messageSize = getFileSize(messageFile); + u32 messageSize = fileRead(message, messageFile, sizeof(message) - 1); - if(messageSize > 0 && messageSize <= 800) + if(messageSize != 0) { - char message[801]; - - if(fileRead(message, messageFile, messageSize) == messageSize) - { - message[messageSize] = 0; - drawString(message, false, 10, 10, COLOR_WHITE); - } + message[messageSize] = 0; + drawString(message, false, 10, 10, COLOR_WHITE); } //Pad to AES block length with zeroes