X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=interpreters%2Fglulxe%2Fglkop.c;h=e761cd73f49a31edf672c3f652449f4f1cf6497d;hb=b1bc17e5adb7183932bb139fa9fe03adf09f3ce9;hp=e9c519128b29d15d6ca3699433d4b814b4519c4b;hpb=5f927b0d7c728e389f3295ac39acb85ecb3a6ef0;p=projects%2Fchimara%2Fchimara.git diff --git a/interpreters/glulxe/glkop.c b/interpreters/glulxe/glkop.c index e9c5191..e761cd7 100644 --- a/interpreters/glulxe/glkop.c +++ b/interpreters/glulxe/glkop.c @@ -468,6 +468,17 @@ static void parse_glk_args(dispatch_splot_t *splot, char **proto, int depth, switch (typeclass) { case 'C': + /* This test checks for a giant array length, which is + deprecated. It displays a warning and cuts it down to + something reasonable. Future releases of this interpreter + may remove this test and go on to verify_array_addresses(), + which treats this case as a fatal error. */ + if (varglist[ix+1] > endmem + || varglist[ix]+varglist[ix+1] > endmem) { + nonfatal_warning_i("Memory access was much too long -- perhaps a print_to_array call with only one argument", varglist[ix+1]); + varglist[ix+1] = endmem - varglist[ix]; + } + verify_array_addresses(varglist[ix], varglist[ix+1], 1); garglist[gargnum].array = AddressOfArray(varglist[ix]); gargnum++; ix++; @@ -476,6 +487,13 @@ static void parse_glk_args(dispatch_splot_t *splot, char **proto, int depth, cx++; break; case 'I': + /* See comment above. */ + if (varglist[ix+1] > endmem/4 + || varglist[ix+1] > (endmem-varglist[ix])/4) { + nonfatal_warning_i("Memory access was much too long -- perhaps a print_to_array call with only one argument", varglist[ix+1]); + varglist[ix+1] = (endmem - varglist[ix]) / 4; + } + verify_array_addresses(varglist[ix], varglist[ix+1], 4); garglist[gargnum].array = CaptureIArray(varglist[ix], varglist[ix+1], passin); gargnum++; ix++;