From 9b8e2b933d01962c1b7a53a313079d641db672f5 Mon Sep 17 00:00:00 2001 From: Aurora Wright Date: Tue, 20 Jun 2017 19:56:34 +0200 Subject: [PATCH] Add missing checks in getFreeK9Space --- source/emunand.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/emunand.c b/source/emunand.c index 0cb23cc..3ead4ee 100644 --- a/source/emunand.c +++ b/source/emunand.c @@ -107,7 +107,8 @@ static inline bool getFreeK9Space(u8 *pos, u32 size, u8 **freeK9Space) //Looking for the last free space before Process9 *freeK9Space = memsearch(pos, pattern, size, sizeof(pattern)); - if(*freeK9Space == NULL) return false; + if(*freeK9Space == NULL || (u32)(pos + size - *freeK9Space) < 0x455 + emunand_bin_size || + *(u32 *)(*freeK9Space + 0x455 + emunand_bin_size - 4) != 0xFFFFFFFF) return false; *freeK9Space += 0x455;