changeset 1218:30c2dbf05841

Add a sanity check for JSSMOD header values.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Mar 2015 09:45:13 +0200
parents 66c79bae8704
children 62a76a3d9bc2
files minijss/jloadjss.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/minijss/jloadjss.c	Thu Mar 05 23:14:15 2015 +0200
+++ b/minijss/jloadjss.c	Fri Mar 06 09:45:13 2015 +0200
@@ -327,6 +327,18 @@
     if (probe)
         return DMERR_OK;
 
+    // Check some of the things for sanity
+    if (jssH.nchannels > jsetMaxChannels ||
+        jssH.nchannels == 0 ||
+        jssH.norders > jsetMaxOrders ||
+        jssH.npatterns > jsetMaxPatterns ||
+        jssH.nextInstruments > jsetMaxInstruments ||
+        jssH.ninstruments > jsetMaxInstruments)
+    {
+        JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA,
+        "Invalid values in JSSMOD header.\n");
+    }
+
     // Allocate the module
     module = jssAllocateModule();
     if (module == NULL)