[gnome-games] nes: Check magic value as raw data



commit 536c7ed9f59319c0694edeb8c90b91de0af5568e
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jan 26 09:58:59 2017 +0100

    nes: Check magic value as raw data
    
    Use DataInputStream instead of StringInputStream to check the Game Boy
    magic value.
    
    This fixes the magic value being incorrectly not found in a valid game
    file.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777777

 plugins/game-boy/src/game-boy-header.vala |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/plugins/game-boy/src/game-boy-header.vala b/plugins/game-boy/src/game-boy-header.vala
index d8a0b35..c449150 100644
--- a/plugins/game-boy/src/game-boy-header.vala
+++ b/plugins/game-boy/src/game-boy-header.vala
@@ -3,7 +3,7 @@
 // Documentation: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header
 private class Games.GameBoyHeader : Object {
        private const size_t MAGIC_OFFSET = 0x104;
-       private const string MAGIC_VALUE = 
"\xce\xed\x66\x66\xcc\x0d\x00\x0b\x03\x73\x00\x83\x00\x0c\x00\x0d\x00\x08\x11\x1f\x88\x89\x00\x0e";
+       private const uint8[] MAGIC_VALUE = { 0xce, 0xed, 0x66, 0x66, 0xcc, 0x0d, 0x00, 0x0b, 0x03, 0x73, 
0x00, 0x83, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x08, 0x11, 0x1f, 0x88, 0x89, 0x00, 0x0e };
 
        private const size_t COLOR_TYPE_OFFSET = 0x143;
        private const uint8 COLOR_ENABLED_VALUE = 0x80;
@@ -92,8 +92,8 @@ private class Games.GameBoyHeader : Object {
        }
 
        public void check_validity () throws Error {
-               var stream = new StringInputStream (file);
-               if (!stream.has_string (MAGIC_OFFSET, MAGIC_VALUE))
+               var stream = new DataInputStream (file);
+               if (!stream.has_data (MAGIC_OFFSET, MAGIC_VALUE))
                        throw new GameBoyError.INVALID_HEADER (_("The file doesn't have a Game Boy header."));
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]