diff --git a/source/qcommon/files.c b/source/qcommon/files.c index 9b70050adb..c5c96d127c 100644 --- a/source/qcommon/files.c +++ b/source/qcommon/files.c @@ -2718,6 +2718,7 @@ static pack_t *FS_LoadPK3File( const char *packfilename, bool silent ) { * * Quick and dirty */ +#define IDPAKENTRY_NAME_SIZE 56 #define IDPAKHEADER ( ( 'K' << 24 ) + ( 'C' << 16 ) + ( 'A' << 8 ) + 'P' ) static pack_t *FS_LoadPakFile( const char *packfilename, bool silent ) { unsigned int i, j; @@ -2729,8 +2730,8 @@ static pack_t *FS_LoadPakFile( const char *packfilename, bool silent ) { pack_t *pack = NULL; // c++ typedef struct { int ident; int dirofs; int dirlen; } fs_header_t; - typedef struct { char name[56]; int filepos, filelen; } fs_info_t; - typedef struct { char name[56]; } fs_dirs_t; + typedef struct { char name[IDPAKENTRY_NAME_SIZE]; int filepos, filelen; } fs_info_t; + typedef struct { char name[IDPAKENTRY_NAME_SIZE]; } fs_dirs_t; fs_header_t header; fs_info_t *info = NULL; fs_dirs_t *dirs = NULL; @@ -2791,6 +2792,9 @@ static pack_t *FS_LoadPakFile( const char *packfilename, bool silent ) { goto error; // something wrong occured } + + info[i].name[IDPAKENTRY_NAME_SIZE-1] = '\0'; // ensure the trailing \0 is there + len = strlen( info[i].name ); if( !len ) { goto error; // something wrong occured