# HG changeset patch # User Matti Hamalainen # Date 1425531702 -7200 # Node ID 92cee852a8af66d9e727f8107e498126db6508a3 # Parent b122ad2d3fbe09b68643ace88a75741100486bcb Check header size against the known values. Bail out if it's too small, and skip unknown data if header specifies larger value than what we read. diff -r b122ad2d3fbe -r 92cee852a8af minijss/jloadxm.c --- a/minijss/jloadxm.c Thu Mar 05 07:00:58 2015 +0200 +++ b/minijss/jloadxm.c Thu Mar 05 07:01:42 2015 +0200 @@ -21,7 +21,7 @@ #define XM_MaxEnvPoints (12) #define XM_MaxNotes (96) #define XM_MaxSampleVolume (64) - +#define XM_HeaderSize 276 /* XM format structures */ @@ -811,6 +811,13 @@ xmH.ninstruments, XM_MaxInstruments); } + if (xmH.headSize < XM_HeaderSize) + { + JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, + "XM header size less than %d bytes (%d bytes).\n", + XM_HeaderSize, xmH.headSize); + } + switch (xmH.version) { case 0x0104: @@ -828,6 +835,14 @@ "Error reading pattern order list.\n"); } + if (xmH.headSize > 276) + { + JSSWARNING(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, + "XM header size > %d bytes, skipping the rest.\n", + XM_HeaderSize, xmH.headSize); + dmfseek(inFile, xmH.headSize - XM_HeaderSize, SEEK_CUR); + } + /* Okay, allocate a module structure */ module = jssAllocateModule();