engine: filesystem: fix loading ZIP files

This commit is contained in:
Alibek Omarov 2022-01-13 17:46:54 +03:00
parent e29dcb4125
commit 606b5354e6

View File

@ -717,7 +717,7 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
int numpackfiles = 0, i; int numpackfiles = 0, i;
zip_cdf_header_t header_cdf; zip_cdf_header_t header_cdf;
zip_header_eocd_t header_eocd; zip_header_eocd_t header_eocd;
uint signature; uint32_t signature;
fs_offset_t filepos = 0, length; fs_offset_t filepos = 0, length;
zipfile_t *info = NULL; zipfile_t *info = NULL;
char filename_buffer[MAX_SYSPATH]; char filename_buffer[MAX_SYSPATH];
@ -794,7 +794,7 @@ static zip_t *FS_LoadZip( const char *zipfile, int *error )
lseek( zip->handle, filepos, SEEK_SET ); lseek( zip->handle, filepos, SEEK_SET );
c = read( zip->handle, &signature, sizeof( signature ) ); c = read( zip->handle, &signature, sizeof( signature ) );
if( c != sizeof( signature ) || signature == ZIP_HEADER_EOCD ) if( c == sizeof( signature ) && signature == ZIP_HEADER_EOCD )
break; break;
filepos -= sizeof( char ); // step back one byte filepos -= sizeof( char ); // step back one byte