The following commit has been merged in the debian-experimental branch:
commit 685b406ce4788b4891ca27a97d2f009dbd56c214
Author: Simon McVittie <[email protected]>
Date:   Thu Aug 4 08:37:20 2011 +0100

    update fake-QVM patch for this snapshot, and restore the ability to load 
replacement shared objects from a subdirectory

diff --git a/debian/changelog b/debian/changelog
index 6ccbbee..c33adb1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,8 @@ ioquake3 (1.36+svn2131-1) UNRELEASED; urgency=low
   * New upstream snapshot
     - drop security patches, no longer needed
     - install the new pluggable renderers
+    - update fake-QVM patch for this snapshot, and restore the ability to
+      load replacement shared objects from a subdirectory
   * Amend previous changelog to include bug numbers, which were not available
     when the package was prepared before the embargo date
   * Add Breaks for openarena versions that don't set the protocol version
diff --git 
a/debian/patches/0002-Add-a-special-vmMagic-that-causes-equivalent-native-.patch
 
b/debian/patches/0002-Add-a-special-vmMagic-that-causes-equivalent-native-.patch
index 9884e8c..2f754ec 100644
--- 
a/debian/patches/0002-Add-a-special-vmMagic-that-causes-equivalent-native-.patch
+++ 
b/debian/patches/0002-Add-a-special-vmMagic-that-causes-equivalent-native-.patch
@@ -1,19 +1,75 @@
+From b2efe45819c6544372e6bb96ff3aae0c52d856a0 Mon Sep 17 00:00:00 2001
 From: Simon McVittie <[email protected]>
-Date: Thu, 10 Mar 2011 23:32:30 +0000
-Subject: Add a special vmMagic that causes equivalent native code to be loaded 
instead
+Date: Thu, 4 Aug 2011 08:36:09 +0100
+Subject: [PATCH] Add a special vmMagic that causes equivalent native code to
+ be loaded instead
 
 This means that mods can build everything from source without relying on
 the non-GPL q3lcc compiler. By padding the fake QVM with bytes chosen
 to match the CRC-32 of the upstream-released QVM, it's even possible to
 be network-compatible with the upstream one, and so play on pure servers.
 
+If the magic number in the fake QVM file is immediately followed by a
+non-empty string (e.g. "pak0"), we try using it as a subdirectory name,
+so we end up loading something like pak0/qagamex86_64.so; otherwise we
+just use the base name, as if for VMI_NATIVE. This is necessary for mods
+like OpenArena, where the game-code for 0.8.1 and 0.8.5 is not
+network-compatible, so 0.8.5 clients on a 0.8.1 pure server need to load
+the 0.8.1 game-code.
+
 Origin: vendor, Debian
 Forwarded: no
 ---
- code/qcommon/qfiles.h |    4 ++++
- code/qcommon/vm.c     |   18 ++++++++++++++++++
- 2 files changed, 22 insertions(+), 0 deletions(-)
+ code/qcommon/files.c   |    6 ++--
+ code/qcommon/qcommon.h |    2 +-
+ code/qcommon/qfiles.h  |    4 +++
+ code/qcommon/vm.c      |   57 +++++++++++++++++++++++++++++++++++++++++++++++-
+ 4 files changed, 64 insertions(+), 5 deletions(-)
 
+diff --git a/code/qcommon/files.c b/code/qcommon/files.c
+index d2e906a..b8e04ee 100644
+--- a/code/qcommon/files.c
++++ b/code/qcommon/files.c
+@@ -1384,7 +1384,7 @@ Return the searchpath in "startSearch".
+ =================
+ */
+ 
+-vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const 
char *name, int enableDll)
++vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const 
char *name, int enableDll, int forceDll)
+ {
+       searchpath_t *search, *lastSearch;
+       directory_t *dir;
+@@ -1408,7 +1408,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, 
int foundlen, const cha
+         
+       while(search)
+       {
+-              if(search->dir && !fs_numServerPaks)
++              if(search->dir && (forceDll || !fs_numServerPaks))
+               {
+                       dir = search->dir;
+ 
+@@ -1431,7 +1431,7 @@ vmInterpret_t FS_FindVM(void **startSearch, char *found, 
int foundlen, const cha
+                               return VMI_COMPILED;
+                       }
+               }
+-              else if(search->pack)
++              else if(search->pack && !forceDll)
+               {
+                       pack = search->pack;
+ 
+diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h
+index eb5e45a..2f93ee4 100644
+--- a/code/qcommon/qcommon.h
++++ b/code/qcommon/qcommon.h
+@@ -624,7 +624,7 @@ qboolean FS_FileExists( const char *file );
+ 
+ qboolean FS_CreatePath (char *OSPath);
+ 
+-vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const 
char *name, int enableDll);
++vmInterpret_t FS_FindVM(void **startSearch, char *found, int foundlen, const 
char *name, int enableDll, int forceDll);
+ 
+ char   *FS_BuildOSPath( const char *base, const char *game, const char *qpath 
);
+ qboolean FS_CompareZipChecksum(const char *zipfile);
 diff --git a/code/qcommon/qfiles.h b/code/qcommon/qfiles.h
 index 7f1ef96..e3515b4 100644
 --- a/code/qcommon/qfiles.h
@@ -30,20 +86,64 @@ index 7f1ef96..e3515b4 100644
        int             vmMagic;
  
 diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c
-index d3fb85b..0b7bbfe 100644
+index c500aea..64cd648 100644
 --- a/code/qcommon/vm.c
 +++ b/code/qcommon/vm.c
-@@ -387,6 +387,18 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
+@@ -370,6 +370,7 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
+       union {
+               vmHeader_t      *h;
+               void                            *v;
++              unsigned char   *bytes;
+       } header;
+ 
+       // load the image
+@@ -390,6 +391,54 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
        // show where the qvm was loaded from
-       Cmd_ExecuteString( va( "which %s\n", filename ) );
+       FS_Which(filename, vm->searchPath);
  
 +      if (LittleLong( header.h->vmMagic ) == VM_MAGIC_USE_NATIVE) {
-+              Com_Printf( "...which has vmMagic VM_MAGIC_USE_NATIVE.\n" );
-+              Com_Printf( "Loading DLL file %s instead.\n", vm->name );
-+              vm->dllHandle = Sys_LoadDll( vm->name, &vm->entryPoint, 
VM_DllSyscall );
-+              if ( !vm->dllHandle ) {
-+                      Com_Printf( "Failed to load DLL.\n" );
-+                      VM_Free( vm );
++              char module[MAX_OSPATH];
++              char filename[MAX_OSPATH];
++              int retval = -1;
++              void *startSearch = NULL;
++
++              Com_Printf("...which has vmMagic VM_MAGIC_USE_NATIVE.\n");
++
++              if (header.bytes[sizeof(int)] != '\0') {
++                      // FS_ReadFileDir guarantees a trailing \0, even if
++                      // there wasn't actually one in the file
++                      Com_sprintf(module, sizeof(module), "%s/%s",
++                              header.bytes + sizeof(int), vm->name);
++                      Com_Printf("... trying %s\n", module);
++                      startSearch = NULL;
++
++                      if (FS_CheckDirTraversal(module)) {
++                              Com_Printf("Directory traversal detected! 
%s\n", module);
++                              VM_Free(vm);
++                              return NULL;
++                      }
++
++                      retval = FS_FindVM(&startSearch, filename, 
sizeof(filename), module, qtrue, qtrue);
++              }
++
++              if (retval != VMI_NATIVE) {
++                      Com_sprintf(module, sizeof(module), "%s", vm->name);
++                      Com_Printf("... trying %s\n", module);
++                      startSearch = NULL;
++
++                      retval = FS_FindVM(&startSearch, filename, 
sizeof(filename), module, qtrue, qtrue);
++              }
++
++              if (retval != VMI_NATIVE) {
++                      VM_Free(vm);
++                      return NULL;
++              }
++
++              Com_Printf("Loading DLL file %s instead.\n", filename);
++              vm->dllHandle = Sys_LoadGameDll(filename, &vm->entryPoint, 
VM_DllSyscall);
++              if (!vm->dllHandle) {
++                      Com_Printf("Failed to load DLL %s.\n", filename);
++                      VM_Free(vm);
 +                      return NULL;
 +              }
 +              return header.h;
@@ -52,9 +152,18 @@ index d3fb85b..0b7bbfe 100644
        if( LittleLong( header.h->vmMagic ) == VM_MAGIC_VER2 ) {
                Com_Printf( "...which has vmMagic VM_MAGIC_VER2\n" );
  
-@@ -573,6 +585,12 @@ vm_t *VM_Create( const char *module, intptr_t 
(*systemCalls)(intptr_t *),
-               return NULL;
-       }
+@@ -573,7 +622,7 @@ vm_t *VM_Create( const char *module, intptr_t 
(*systemCalls)(intptr_t *),
+ 
+       do
+       {
+-              retval = FS_FindVM(&startSearch, filename, sizeof(filename), 
module, (interpret == VMI_NATIVE));
++              retval = FS_FindVM(&startSearch, filename, sizeof(filename), 
module, (interpret == VMI_NATIVE), qfalse);
+               
+               if(retval == VMI_NATIVE)
+               {
+@@ -605,6 +654,12 @@ vm_t *VM_Create( const char *module, intptr_t 
(*systemCalls)(intptr_t *),
+ 
+       vm->systemCall = systemCalls;
  
 +      if ( vm->dllHandle ) {
 +              // it was replaced by a DLL anyway
@@ -64,5 +173,7 @@ index d3fb85b..0b7bbfe 100644
 +
        // allocate space for the jump targets, which will be filled in by the 
compile/prep functions
        vm->instructionCount = header->instructionCount;
-       vm->instructionPointers = Hunk_Alloc( vm->instructionCount*4, h_high );
+       vm->instructionPointers = Hunk_Alloc(vm->instructionCount * 
sizeof(*vm->instructionPointers), h_high);
 -- 
+1.7.5.4
+

-- 
Quake 3 engine

_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to