[chocolate-doom] 38/42: Check the header of dehacked files and make sure we only load valid dehacked files.

Jonathan Dowland jmtd at moszumanska.debian.org
Mon Jan 30 15:06:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

jmtd pushed a commit to annotated tag chocolate-doom-0.1.0
in repository chocolate-doom.

commit c8b201dd2ad041eda3147b59abaacb2d2359c6d5
Author: Simon Howard <fraggle at gmail.com>
Date:   Sun Oct 9 20:06:50 2005 +0000

    Check the header of dehacked files and make sure we only load valid
    dehacked files.
    
    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 182
---
 src/deh_main.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/deh_main.c b/src/deh_main.c
index ef06f09..0f252b7 100644
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: deh_main.c 174 2005-10-08 20:14:38Z fraggle $
+// $Id: deh_main.c 182 2005-10-09 20:06:50Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.6  2005/10/09 20:06:50  fraggle
+// Check the header of dehacked files and make sure we only load valid
+// dehacked files.
+//
 // Revision 1.5  2005/10/08 20:14:38  fraggle
 // Dehacked "Sound" section support
 //
@@ -54,6 +58,8 @@
 #include "deh_defs.h"
 #include "deh_io.h"
 
+static char deh_signature[] = "Patch File for DeHackEd v3.0\n";
+
 // deh_ammo.c:
 extern deh_section_t deh_section_ammo;
 // deh_cheat.c:
@@ -196,6 +202,21 @@ boolean DEH_ParseAssignment(char *line, char **variable_name, char **value)
     return true;
 }
 
+static boolean CheckSignature(deh_context_t *context)
+{
+    int i;
+
+    for (i=0; i<strlen(deh_signature); ++i)
+    {
+        int c = DEH_GetChar(context);
+
+        if (c != deh_signature[i])
+            return false;
+    }
+
+    return true;
+}
+
 // Parses a dehacked file by reading from the context
 
 static void DEH_ParseContext(deh_context_t *context)
@@ -205,6 +226,15 @@ static void DEH_ParseContext(deh_context_t *context)
     void *tag = NULL;
     char *line;
     
+    // Read the header and check it matches the signature
+
+    if (!CheckSignature(context))
+    {
+        DEH_Error(context, "This is not a dehacked v3.0 patch file!");
+    }
+    
+    // Read the file
+    
     for (;;) 
     {
         // read a new line

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/chocolate-doom.git



More information about the Pkg-games-commits mailing list