]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
bsp lump write: pad with zeros, not with random unitialized memory data
authorThomas Debesse <dev@illwieckz.net>
Tue, 14 Jan 2020 07:06:47 +0000 (08:06 +0100)
committerThomas Debesse <dev@illwieckz.net>
Thu, 23 Jan 2020 18:21:39 +0000 (19:21 +0100)
tools/quake3/q3map2/bspfile_abstract.c

index fb8af399eddda89e06c3165cf9271cbdb5ef30ed..62beb16a141b6409d4066c939cb0c579f4bc1eee 100644 (file)
@@ -341,14 +341,17 @@ int CopyLump_Allocate( bspHeader_t *header, int lump, void **dest, int size, int
 void AddLump( FILE *file, bspHeader_t *header, int lumpNum, const void *data, int length ){
        bspLump_t   *lump;
 
-
        /* add lump to bsp file header */
        lump = &header->lumps[ lumpNum ];
        lump->offset = LittleLong( ftell( file ) );
        lump->length = LittleLong( length );
 
        /* write lump to file */
-       SafeWrite( file, data, ( length + 3 ) & ~3 );
+       SafeWrite( file, data, length );
+
+       /* write padding zeros */
+       char *zeros[3] = { 0, 0, 0 };
+       SafeWrite( file, zeros, ( ( length + 3 ) & ~3 ) - length );
 }