Skip to content

Commit

Permalink
Fix UTF-8 BOM (Windows Notepad seems to like it) being parsed as a re…
Browse files Browse the repository at this point in the history
…gular character
  • Loading branch information
AuroraWright committed Sep 16, 2016
1 parent de6f978 commit f5039dc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions injector/source/patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@ static void loadCustomVerString(u16 *out, u32 *verStringSize)
{
u64 fileSize;

if(R_SUCCEEDED(IFile_GetSize(&file, &fileSize)) && fileSize <= 57)
if(R_SUCCEEDED(IFile_GetSize(&file, &fileSize)) && fileSize <= 60)
{
u8 buf[57];
u8 buf[fileSize];
u64 total;

if(R_SUCCEEDED(IFile_Read(&file, &total, buf, fileSize)))
{
static const u8 bom[] = {0xEF, 0xBB, 0xBF};
u32 finalSize = 0;

for(u32 i = 0, fileSizeTmp = (u32)fileSize, increase; i < fileSizeTmp && finalSize <= 18; i += increase)
for(u32 increase, fileSizeTmp = (u32)fileSize, i = (fileSizeTmp > 2 && memcmp(buf, bom, sizeof(bom)) == 0) ? 3 : 0;
i < fileSizeTmp && finalSize < 19; i += increase)
{
if((buf[i] & 0x80) == 0)
{
Expand Down

0 comments on commit f5039dc

Please sign in to comment.