Crash in FRUA spec code when clicking on Treasure game.ovr


GBE crashes is the FruaGlbFileSpecifcation trying to read the reader.ReadChars(4) as it treats the data as RTF8 string.
So as it's a byte string just, read a Uint, and then compare to the "text" equivalent in hex (but reversed) like so:
                //var headerText = new string(reader.ReadChars(4));
                var headerText = reader.ReadUInt32();
                var fileSize = reader.ReadInt32();
                var entries = reader.ReadInt32();
                //var dataText = new string(reader.ReadChars(4));
                var dataText = reader.ReadUInt32();
                return headerText == 0x42494C48 /* "HLIB" */ &&
                       dataText == 0x41544144 /* "DATA" */ &&
                       fileSize == new FileInfo(parameters.FullPath).Length;
also move the second string compare before to file size read, as the later is more costly.
Closed Feb 21, 2011 at 2:33 PM by bsimser


SimeonPilgrim wrote Oct 29, 2010 at 8:52 PM

You also want to add a
            if (stream.Length < 16) return false;
at the start to avoid small files

SimeonPilgrim wrote Nov 9, 2010 at 2:43 PM

Applied the change here (and in patch 7221) minus the comment lines.

wrote Feb 21, 2011 at 12:27 PM

wrote Feb 21, 2011 at 2:33 PM

wrote Feb 13, 2013 at 10:27 PM

wrote May 16, 2013 at 5:52 AM