Fixed possible issue with the injector

This commit is contained in:
Aurora 2016-04-11 17:57:22 +02:00
parent d4d281bb9c
commit 7479bf8092

View File

@ -44,16 +44,15 @@ static u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, in
{ {
u8 *found = memsearch(start, pattern, size, patSize); u8 *found = memsearch(start, pattern, size, patSize);
if(found == NULL) if(found == NULL) break;
break;
memcpy(found + offset, replace, repSize); memcpy(found + offset, replace, repSize);
u32 at = (u32)(found - start); u32 at = (u32)(found - start);
if(at + patSize > size) size = 0; if(at + patSize > size) break;
else size = size - (at + patSize);
size -= at + patSize;
start = found + patSize; start = found + patSize;
} }
@ -72,7 +71,7 @@ static int fileOpen(IFile *file, FS_ArchiveID id, const char *path, int flags)
archive.lowPath.data = (u8 *)""; archive.lowPath.data = (u8 *)"";
ppath.type = PATH_ASCII; ppath.type = PATH_ASCII;
ppath.data = path; ppath.data = path;
ppath.size = len+1; ppath.size = len + 1;
return IFile_Open(file, archive, ppath, flags); return IFile_Open(file, archive, ppath, flags);
} }