]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
Merge MR 'Move SDL_GL_GetProcAddress after creating GL context'
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 87367a77c28ed8a6c61803519a1a6a46033cd2da..747ace822e63c840af846ee1d80d780902b7b17d 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -682,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
@@ -699,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;
@@ -743,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;
        }
@@ -3242,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;