]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
fix support for zip archives made by the standard Mac OSX archiver
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 3e3820ed1c249705f3ad516fb86f4601de076b5f..1eded56cf09094516dfa8d260e1227dd08fe94cc 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -481,9 +481,16 @@ int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd)
                // Check encryption, compression, and attributes
                // 1st uint8  : general purpose bit flag
                //    Check bits 0 (encryption), 3 (data descriptor after the file), and 5 (compressed patched data (?))
+               //
+               // LordHavoc: bit 3 would be a problem if we were scanning the archive
+               // but is not a problem in the central directory where the values are
+               // always real.
+               //
+               // bit 3 seems to always be set by the standard Mac OSX zip maker
+               //
                // 2nd uint8 : external file attributes
                //    Check bits 3 (file is a directory) and 5 (file is a volume (?))
-               if ((ptr[8] & 0x29) == 0 && (ptr[38] & 0x18) == 0)
+               if ((ptr[8] & 0x21) == 0 && (ptr[38] & 0x18) == 0)
                {
                        // Still enough bytes for the name?
                        if (remaining < namesize || namesize >= (int)sizeof (*pack->files))
@@ -1808,17 +1815,6 @@ Open a file. The syntax is the same as fopen
 */
 qfile_t* FS_Open (const char* filepath, const char* mode, qboolean quiet, qboolean nonblocking)
 {
-#ifdef FS_FIX_PATHS
-       char fixedFileName[MAX_QPATH];
-       char *d;
-       strlcpy( fixedFileName, filepath, MAX_QPATH );
-       // try to fix common mistakes (\ instead of /)
-       for( d = fixedFileName ; *d ; d++ )
-               if( *d == '\\' )
-                       *d = '/';
-       filepath = fixedFileName;
-#endif
-
        if (FS_CheckNastyPath(filepath, false))
        {
                Con_Printf("FS_Open(\"%s\", \"%s\", %s): nasty filename rejected\n", filepath, mode, quiet ? "true" : "false");
@@ -2633,11 +2629,11 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet)
                                // copy everything up except nextseperator
                                strlcpy(subpattern, pattern, min(sizeof(subpattern), (size_t) (nextseparator - pattern + 1)));
                                // find the last '/' before the wildcard
-                               prevseparator = strrchr( subpattern, '/' ) + 1;
+                               prevseparator = strrchr( subpattern, '/' );
                                if (!prevseparator)
-                               {
                                        prevseparator = subpattern;
-                               }
+                               else
+                                       prevseparator++;
                                // copy everything from start to the previous including the '/' (before the wildcard)
                                // everything up to start is already included in the path of matchedSet's entries
                                strlcpy(subpath, start, min(sizeof(subpath), (size_t) ((prevseparator - subpattern) - (start - pattern) + 1)));