@colyseus/schema 3.0.65 → 3.0.67

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.
@@ -336,6 +336,10 @@ const _float64 = new Float64Array(_convoBuffer);
336
336
  const _uint64 = new BigUint64Array(_convoBuffer);
337
337
  const _int64 = new BigInt64Array(_convoBuffer);
338
338
  function utf8Read(bytes, it, length) {
339
+ // boundary check
340
+ if (length > bytes.length - it.offset) {
341
+ length = bytes.length - it.offset;
342
+ }
339
343
  var string = '', chr = 0;
340
344
  for (var i = it.offset, end = it.offset + length; i < end; i++) {
341
345
  var byte = bytes[i];
@@ -368,9 +372,10 @@ function utf8Read(bytes, it, length) {
368
372
  }
369
373
  continue;
370
374
  }
371
- console.error('Invalid byte ' + byte.toString(16));
372
375
  // (do not throw error to avoid server/client from crashing due to hack attemps)
373
376
  // throw new Error('Invalid byte ' + byte.toString(16));
377
+ console.error('decode.utf8Read(): Invalid byte ' + byte + ' at offset ' + i + '. Skip to end of string: ' + (it.offset + length));
378
+ break;
374
379
  }
375
380
  it.offset += length;
376
381
  return string;