X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=fs.c;h=747ace822e63c840af846ee1d80d780902b7b17d;hb=refs%2Fheads%2Fdiv0-stable;hp=1dfc97f1857234c2816099576dd3fda480af33cc;hpb=07f459ff32baea233afcd025447039f33dab235f;p=xonotic%2Fdarkplaces.git diff --git a/fs.c b/fs.c index 1dfc97f1..747ace82 100644 --- a/fs.c +++ b/fs.c @@ -74,7 +74,6 @@ # define dup _dup #endif -#define USE_RWOPS 1 #if USE_RWOPS # include typedef SDL_RWops *filedesc_t; @@ -683,7 +682,7 @@ static int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd) return -1; } - namesize = BuffLittleShort (&ptr[28]); // filename length + namesize = (unsigned short)BuffLittleShort (&ptr[28]); // filename length // Check encryption, compression, and attributes // 1st uint8 : general purpose bit flag @@ -700,7 +699,7 @@ static int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd) if ((ptr[8] & 0x21) == 0 && (ptr[38] & 0x18) == 0) { // Still enough bytes for the name? - if (namesize < 0 || remaining < namesize || namesize >= (int)sizeof (*pack->files)) + if (remaining < namesize || namesize >= (int)sizeof (*pack->files)) { Mem_Free (central_dir); return -1; @@ -744,7 +743,7 @@ static int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd) // Skip the name, additionnal field, and comment // 1er uint16 : extra field length // 2eme uint16 : file comment length - count = namesize + BuffLittleShort (&ptr[30]) + BuffLittleShort (&ptr[32]); + count = namesize + (unsigned short)BuffLittleShort (&ptr[30]) + (unsigned short)BuffLittleShort (&ptr[32]); ptr += ZIP_CDIR_CHUNK_BASE_SIZE + count; remaining -= count; } @@ -3243,9 +3242,9 @@ int FS_Seek (qfile_t* file, fs_offset_t offset, int whence) buffer = (unsigned char *)Mem_Alloc (tempmempool, buffersize); // Skip all data until we reach the requested offset - while (offset > file->position) + while (offset > (file->position - file->buff_len + file->buff_ind)) { - fs_offset_t diff = offset - file->position; + fs_offset_t diff = offset - (file->position - file->buff_len + file->buff_ind); fs_offset_t count, len; count = (diff > buffersize) ? buffersize : diff; @@ -3567,7 +3566,6 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) stringlist_t dirlist; const char *slash, *backslash, *colon, *separator; char *basepath; - char temp[MAX_OSPATH]; for (i = 0;pattern[i] == '.' || pattern[i] == ':' || pattern[i] == '/' || pattern[i] == '\\';i++) ; @@ -3602,6 +3600,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) pak = searchpath->pack; for (i = 0;i < pak->numfiles;i++) { + char temp[MAX_OSPATH]; strlcpy(temp, pak->files[i].name, sizeof(temp)); while (temp[0]) { @@ -3685,6 +3684,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) // for each entry in matchedSet try to open the subdirectories specified in subpath for( dirlistindex = 0 ; dirlistindex < matchedSet.numstrings ; dirlistindex++ ) { + char temp[MAX_OSPATH]; strlcpy( temp, matchedSet.strings[ dirlistindex ], sizeof(temp) ); strlcat( temp, subpath, sizeof(temp) ); listdirectory( &foundSet, searchpath->filename, temp ); @@ -3708,17 +3708,17 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) for (dirlistindex = 0;dirlistindex < matchedSet.numstrings;dirlistindex++) { - const char *temp = matchedSet.strings[dirlistindex]; - if (matchpattern(temp, (char *)pattern, true)) + const char *matchtemp = matchedSet.strings[dirlistindex]; + if (matchpattern(matchtemp, (char *)pattern, true)) { for (resultlistindex = 0;resultlistindex < resultlist.numstrings;resultlistindex++) - if (!strcmp(resultlist.strings[resultlistindex], temp)) + if (!strcmp(resultlist.strings[resultlistindex], matchtemp)) break; if (resultlistindex == resultlist.numstrings) { - stringlistappend(&resultlist, temp); + stringlistappend(&resultlist, matchtemp); if (!quiet && developer_loading.integer) - Con_Printf("SearchDirFile: %s\n", temp); + Con_Printf("SearchDirFile: %s\n", matchtemp); } } }