From 5e8990f5714c0fefdb4ec414cad0458764678ab2 Mon Sep 17 00:00:00 2001 From: Aurora Date: Thu, 22 Sep 2016 15:35:28 +0200 Subject: [PATCH] Fix derp --- diffs/1.diff | 4 ++-- source/patches.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/diffs/1.diff b/diffs/1.diff index ff6f750..dcbddb1 100644 --- a/diffs/1.diff +++ b/diffs/1.diff @@ -49,7 +49,7 @@ diff -uNr a/source/brahma.c b/source/brahma.c + if (p) { + fseek(p , 0, SEEK_END); + psize = ftell(p); -+ if (psize > 5 && psize < 39) { ++ if (psize > 5 && psize < 40) { + char path[psize + 1]; + + fseek(p, 0, SEEK_SET); @@ -58,7 +58,7 @@ diff -uNr a/source/brahma.c b/source/brahma.c + if (bytes_read == psize) { + if (path[psize - 1] == 0xA) psize--; + if (path[psize - 1] == 0xD) psize--; -+ if (psize > 5 && path[0] == '/' && memcmp(&path[psize - 4], ".bin", 4)) { ++ if (psize > 5 && psize < 38 && path[0] == '/' && memcmp(&path[psize - 4], ".bin", 4)) { + path[psize] = 0; + f = fopen(path, "rb"); + use_default = false; diff --git a/source/patches.c b/source/patches.c index cf00192..e1f3606 100644 --- a/source/patches.c +++ b/source/patches.c @@ -102,14 +102,14 @@ void patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr) u32 pathSize = getFileSize(pathPath); - if(pathSize > 5 && pathSize < 39) + if(pathSize > 5 && pathSize < 40) { u8 path[pathSize]; fileRead(path, pathPath, 0); if(path[pathSize - 1] == 0xA) pathSize--; if(path[pathSize - 1] == 0xD) pathSize--; - if(pathSize > 5 && path[0] == '/' && memcmp(&path[pathSize - 4], ".bin", 4) == 0) + if(pathSize > 5 && pathSize < 38 && path[0] == '/' && memcmp(&path[pathSize - 4], ".bin", 4) == 0) { u16 finalPath[pathSize + 1]; for(u32 i = 0; i < pathSize; i++) @@ -117,7 +117,7 @@ void patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr) finalPath[pathSize] = 0; u8 *pos_path = memsearch(off, u"sd", reboot_size, 4) + 0xA; - memcpy(pos_path, finalPath, pathSize); + memcpy(pos_path, finalPath, (pathSize + 1) * 2); } } }