]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
Fix underflow in various commands when using an empty file name.
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 5db59551e8f28a987adf89dab1960a2b74136121..817780f79dec258af9ada9984557472d41748502 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -587,8 +587,8 @@ static qboolean PK3_GetEndOfCentralDir (const char *packfile, int packhandle, pk
        Mem_Free (buffer);
 
        if (
-                       eocd->cdir_size < 0 || eocd->cdir_size > filesize ||
-                       eocd->cdir_offset < 0 || eocd->cdir_offset >= filesize ||
+                       eocd->cdir_size > filesize ||
+                       eocd->cdir_offset >= filesize ||
                        eocd->cdir_offset + eocd->cdir_size > filesize
           )
        {
@@ -2759,7 +2759,7 @@ fs_offset_t FS_Write (qfile_t* file, const void* data, size_t datasize)
        {
                if (lseek (file->handle, file->buff_ind - file->buff_len, SEEK_CUR) == -1)
                {
-                       Con_Printf("WARNING: could not seek in %s.\n");
+                       Con_Printf("WARNING: could not seek in %s.\n", file->filename);
                }
        }
 
@@ -3350,7 +3350,7 @@ void FS_DefaultExtension (char *path, const char *extension, size_t size_path)
 
        // if path doesn't have a .EXT, append extension
        // (extension should include the .)
-       src = path + strlen(path) - 1;
+       src = path + strlen(path);
 
        while (*src != '/' && src != path)
        {
@@ -3935,8 +3935,7 @@ unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflat
                return NULL;
        }
 
-       if(deflated_size)
-               *deflated_size = (size_t)strm.total_out;
+       *deflated_size = (size_t)strm.total_out;
 
        memcpy(out, tmp, strm.total_out);
        Mem_Free(tmp);
@@ -4050,8 +4049,7 @@ unsigned char *FS_Inflate(const unsigned char *data, size_t size, size_t *inflat
        memcpy(out, outbuf.data, outbuf.cursize);
        Mem_Free(outbuf.data);
 
-       if(inflated_size)
-               *inflated_size = (size_t)outbuf.cursize;
+       *inflated_size = (size_t)outbuf.cursize;
        
        return out;
 }