@colyseus/schema 3.0.65 → 3.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -338,6 +338,10 @@ const _float64 = new Float64Array(_convoBuffer);
338
338
  const _uint64 = new BigUint64Array(_convoBuffer);
339
339
  const _int64 = new BigInt64Array(_convoBuffer);
340
340
  function utf8Read(bytes, it, length) {
341
+ // boundary check
342
+ if (length > bytes.length - it.offset) {
343
+ length = bytes.length - it.offset;
344
+ }
341
345
  var string = '', chr = 0;
342
346
  for (var i = it.offset, end = it.offset + length; i < end; i++) {
343
347
  var byte = bytes[i];
@@ -370,9 +374,10 @@ function utf8Read(bytes, it, length) {
370
374
  }
371
375
  continue;
372
376
  }
373
- console.error('Invalid byte ' + byte.toString(16));
374
377
  // (do not throw error to avoid server/client from crashing due to hack attemps)
375
378
  // throw new Error('Invalid byte ' + byte.toString(16));
379
+ console.error('decode.utf8Read(): Invalid byte ' + byte + ' at offset ' + i + '. Skip to end of string: ' + (it.offset + length));
380
+ break;
376
381
  }
377
382
  it.offset += length;
378
383
  return string;