protobufjs 7.6.4 → 7.6.6

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v7.6.4 (c) 2016, daniel wirtz
3
- * compiled fri, 12 jun 2026 12:10:46 utc
2
+ * protobuf.js v7.6.6 (c) 2016, daniel wirtz
3
+ * compiled thu, 27 aug 2026 10:13:18 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -1468,7 +1468,17 @@ function decoder(mtype) {
1468
1468
  ("if(n===undefined)n=0")
1469
1469
  ("if(n>Reader.recursionLimit)")
1470
1470
  ("throw Error(\"maximum nesting depth exceeded\")")
1471
- ("var c=l===undefined?r.len:r.pos+l,m=new this.ctor" + (mtype.fieldsArray.filter(function(field) { return field.map; }).length ? ",k,value" : ""))
1471
+ ("var c,m" + (mtype.fieldsArray.filter(function(field) { return field.map; }).length ? ",k,value" : ""))
1472
+ ("if(l===undefined)")
1473
+ ("c=r.len")
1474
+ ("else{")
1475
+ ("c=r.pos+l")
1476
+ ("if(c>r.len)")
1477
+ ("throw RangeError(\"index out of range\")")
1478
+ ("l=r.len")
1479
+ ("r.len=c")
1480
+ ("}")
1481
+ ("m=new this.ctor")
1472
1482
  ("while(r.pos<c){")
1473
1483
  ("var t=r.uint32()")
1474
1484
  ("if(t===e)")
@@ -1486,7 +1496,10 @@ function decoder(mtype) {
1486
1496
  if (field.map) { gen
1487
1497
  ("if(%s===util.emptyObject)", ref)
1488
1498
  ("%s={}", ref)
1489
- ("var c2 = r.uint32()+r.pos");
1499
+ ("var c2=r.uint32()+r.pos")
1500
+ ("if(c2>r.len)")
1501
+ ("throw RangeError(\"index out of range\")")
1502
+ ("r.len=c2");
1490
1503
 
1491
1504
  if (types.defaults[field.keyType] !== undefined) gen
1492
1505
  ("k=%j", types.defaults[field.keyType]);
@@ -1516,7 +1529,10 @@ function decoder(mtype) {
1516
1529
  ("r.skipType(tag2&7,n)")
1517
1530
  ("break")
1518
1531
  ("}")
1519
- ("}");
1532
+ ("}")
1533
+ ("if(r.pos!==c2)")
1534
+ ("throw RangeError(\"index out of range\")")
1535
+ ("r.len=c");
1520
1536
 
1521
1537
  if (types.long[field.keyType] !== undefined) gen
1522
1538
  ("%s[typeof k===\"object\"?util.longToHash(k):k]=value", ref);
@@ -1538,8 +1554,14 @@ function decoder(mtype) {
1538
1554
  if (types.packed[type] !== undefined) gen
1539
1555
  ("if((t&7)===2){")
1540
1556
  ("var c2=r.uint32()+r.pos")
1557
+ ("if(c2>r.len)")
1558
+ ("throw RangeError(\"index out of range\")")
1559
+ ("r.len=c2")
1541
1560
  ("while(r.pos<c2)")
1542
1561
  ("%s.push(r.%s())", ref, type)
1562
+ ("if(r.pos!==c2)")
1563
+ ("throw RangeError(\"index out of range\")")
1564
+ ("r.len=c")
1543
1565
  ("}else");
1544
1566
 
1545
1567
  // Non-packed
@@ -1567,6 +1589,13 @@ function decoder(mtype) {
1567
1589
  ("}")
1568
1590
  ("}");
1569
1591
 
1592
+ gen
1593
+ ("if(l!==undefined){")
1594
+ ("if(r.pos!==c)")
1595
+ ("throw RangeError(\"index out of range\")")
1596
+ ("r.len=l")
1597
+ ("}");
1598
+
1570
1599
  // Field presence
1571
1600
  for (i = 0; i < mtype._fieldsArray.length; ++i) {
1572
1601
  var rfield = mtype._fieldsArray[i];
@@ -4196,6 +4225,20 @@ Reader.create = create();
4196
4225
 
4197
4226
  Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;
4198
4227
 
4228
+ function readVarint32NearEnd(reader) {
4229
+ // Safely read up to four bytes of a varint32 near the reader limit
4230
+ var value = 0;
4231
+ for (var i = 0; i < 4; ++i) {
4232
+ if (reader.pos >= reader.len)
4233
+ throw indexOutOfRange(reader);
4234
+ var b = reader.buf[reader.pos++];
4235
+ value = (value | (b & 127) << i * 7) >>> 0;
4236
+ if (b < 128)
4237
+ return value;
4238
+ }
4239
+ throw indexOutOfRange(reader);
4240
+ }
4241
+
4199
4242
  /**
4200
4243
  * Reads a varint as an unsigned 32 bit value.
4201
4244
  * @function
@@ -4204,6 +4247,12 @@ Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore ne
4204
4247
  Reader.prototype.uint32 = (function read_uint32_setup() {
4205
4248
  var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)
4206
4249
  return function read_uint32() {
4250
+ if (this.len - this.pos < 5) {
4251
+ if (this.pos >= this.len)
4252
+ throw indexOutOfRange(this);
4253
+ if (this.buf[this.pos] >= 128)
4254
+ return readVarint32NearEnd(this);
4255
+ }
4207
4256
  value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;
4208
4257
  value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;
4209
4258
  value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;
@@ -7413,6 +7462,10 @@ var Message = require(20),
7413
7462
  wrappers[".google.protobuf.Any"] = {
7414
7463
 
7415
7464
  fromObject: function(object, depth) {
7465
+ if (depth === undefined)
7466
+ depth = 0;
7467
+ if (depth > util.recursionLimit)
7468
+ throw Error("max depth exceeded");
7416
7469
 
7417
7470
  // unwrap value type if mapped
7418
7471
  if (object && object["@type"]) {
@@ -7430,7 +7483,7 @@ wrappers[".google.protobuf.Any"] = {
7430
7483
  }
7431
7484
  return this.create({
7432
7485
  type_url: type_url,
7433
- value: type.encode(type.fromObject(object, depth === undefined ? 1 : depth + 1)).finish()
7486
+ value: type.encode(type.fromObject(object, depth + 1)).finish()
7434
7487
  });
7435
7488
  }
7436
7489
  }