ref: 4fe3d6949dfb99a200f14480003c5b6b5e2c5a55
parent: 2c65634c88ea7564deb4df78c529b929027e477f
author: Christopher Snowhill <kode54@gmail.com>
date: Sun Oct 8 13:10:46 EDT 2017
Limit total order count to something somewhat reasonable in formats that otherwise allow up to a full 65536 orders, which tends to blow our timekeeping arrays way out of proportion, eating huge amounts of memory.
--- a/src/it/itread.c
+++ b/src/it/itread.c
@@ -1042,6 +1042,7 @@
// XXX sample count
if (dumbfile_error(f) || sigdata->n_orders <= 0 ||
+ sigdata->n_orders > 1024 || // Whoa, nelly.
sigdata->n_instruments > 256 || sigdata->n_samples > 4000 ||
sigdata->n_patterns > 256) {
_dumb_it_unload_sigdata(sigdata);
--- a/src/it/readdsmf.c
+++ b/src/it/readdsmf.c
@@ -293,6 +293,8 @@
sigdata->flags = IT_STEREO | IT_OLD_EFFECTS | IT_COMPATIBLE_GXX;
dumbfile_skip(f, 36 - 28);
sigdata->n_orders = dumbfile_igetw(f);
+ if (sigdata->n_orders > 1024) // Whoa, nelly.
+ goto error_usd;
// sigdata->n_samples = ptr[ 38 ] | ( ptr[ 39 ] << 8 ); // whatever
// sigdata->n_patterns = ptr[ 40 ] | ( ptr[ 41 ] << 8 );
dumbfile_skip(f, 42 - 38);
--- a/src/it/readptm.c
+++ b/src/it/readptm.c
@@ -352,6 +352,7 @@
sigdata->n_patterns = dumbfile_igetw(f);
if (dumbfile_error(f) || sigdata->n_orders <= 0 ||
+ sigdata->n_orders > 1024 || // Whoa, nelly.
sigdata->n_samples > 255 || sigdata->n_patterns > 128) {
_dumb_it_unload_sigdata(sigdata);
return NULL;
--- a/src/it/reads3m.c
+++ b/src/it/reads3m.c
@@ -480,6 +480,7 @@
sigdata->n_patterns = dumbfile_igetw(f);
if (dumbfile_error(f) || sigdata->n_orders <= 0 ||
+ sigdata->n_orders > 1024 || // Whoa, nelly.
sigdata->n_samples > 256 || sigdata->n_patterns > 256) {
_dumb_it_unload_sigdata(sigdata);
return NULL;