# HG changeset patch # User Tero Marttila # Date 1397238385 -10800 # Node ID 2957be8573b9fc3849aa60c42865a9491bfcb5e4 # Parent 24f00b561a4a0b72a3c75bea24c2d6769a60d40c dmx: fill: actually enforce end, don't overrun if fill sequence is longer diff -r 24f00b561a4a -r 2957be8573b9 src/hello-dmx.c --- a/src/hello-dmx.c Fri Apr 11 19:51:19 2014 +0300 +++ b/src/hello-dmx.c Fri Apr 11 20:46:25 2014 +0300 @@ -140,12 +140,17 @@ return '!'; } + if (end >= DMX_COUNT) { + return '!'; + } + // apply // arg is 1..256 byte c = start - 1; - for ( ; c < end && c < DMX_COUNT - 1; ) { - for (byte a = 2; a < console.argc && c < DMX_COUNT - 1; a++) { + // c < end actually means inclusive to end of range, as the index is -1 + for ( ; c < end; ) { + for (byte a = 2; a < console.argc && c < end; a++) { dmx.out[c++] = console.argv[a]; } }