]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fs: Use unsigned short for filename size
authorCloudwalk <cloudwalk@icculus.org>
Fri, 24 Mar 2023 13:54:31 +0000 (09:54 -0400)
committerCloudwalk <cloudwalk@icculus.org>
Fri, 24 Mar 2023 13:54:31 +0000 (09:54 -0400)
Also remove namesize < 0 check as this is no longer possible

fs.c

diff --git a/fs.c b/fs.c
index 1fecfddb3dd3c7ef09e904ba685034a3d8856cab..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;