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.
package/dist/protobuf.js CHANGED
@@ -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
  */
@@ -1869,7 +1869,17 @@ function decoder(mtype) {
1869
1869
  ("if(n===undefined)n=0")
1870
1870
  ("if(n>Reader.recursionLimit)")
1871
1871
  ("throw Error(\"maximum nesting depth exceeded\")")
1872
- ("var c=l===undefined?r.len:r.pos+l,m=new this.ctor" + (mtype.fieldsArray.filter(function(field) { return field.map; }).length ? ",k,value" : ""))
1872
+ ("var c,m" + (mtype.fieldsArray.filter(function(field) { return field.map; }).length ? ",k,value" : ""))
1873
+ ("if(l===undefined)")
1874
+ ("c=r.len")
1875
+ ("else{")
1876
+ ("c=r.pos+l")
1877
+ ("if(c>r.len)")
1878
+ ("throw RangeError(\"index out of range\")")
1879
+ ("l=r.len")
1880
+ ("r.len=c")
1881
+ ("}")
1882
+ ("m=new this.ctor")
1873
1883
  ("while(r.pos<c){")
1874
1884
  ("var t=r.uint32()")
1875
1885
  ("if(t===e)")
@@ -1887,7 +1897,10 @@ function decoder(mtype) {
1887
1897
  if (field.map) { gen
1888
1898
  ("if(%s===util.emptyObject)", ref)
1889
1899
  ("%s={}", ref)
1890
- ("var c2 = r.uint32()+r.pos");
1900
+ ("var c2=r.uint32()+r.pos")
1901
+ ("if(c2>r.len)")
1902
+ ("throw RangeError(\"index out of range\")")
1903
+ ("r.len=c2");
1891
1904
 
1892
1905
  if (types.defaults[field.keyType] !== undefined) gen
1893
1906
  ("k=%j", types.defaults[field.keyType]);
@@ -1917,7 +1930,10 @@ function decoder(mtype) {
1917
1930
  ("r.skipType(tag2&7,n)")
1918
1931
  ("break")
1919
1932
  ("}")
1920
- ("}");
1933
+ ("}")
1934
+ ("if(r.pos!==c2)")
1935
+ ("throw RangeError(\"index out of range\")")
1936
+ ("r.len=c");
1921
1937
 
1922
1938
  if (types.long[field.keyType] !== undefined) gen
1923
1939
  ("%s[typeof k===\"object\"?util.longToHash(k):k]=value", ref);
@@ -1939,8 +1955,14 @@ function decoder(mtype) {
1939
1955
  if (types.packed[type] !== undefined) gen
1940
1956
  ("if((t&7)===2){")
1941
1957
  ("var c2=r.uint32()+r.pos")
1958
+ ("if(c2>r.len)")
1959
+ ("throw RangeError(\"index out of range\")")
1960
+ ("r.len=c2")
1942
1961
  ("while(r.pos<c2)")
1943
1962
  ("%s.push(r.%s())", ref, type)
1963
+ ("if(r.pos!==c2)")
1964
+ ("throw RangeError(\"index out of range\")")
1965
+ ("r.len=c")
1944
1966
  ("}else");
1945
1967
 
1946
1968
  // Non-packed
@@ -1968,6 +1990,13 @@ function decoder(mtype) {
1968
1990
  ("}")
1969
1991
  ("}");
1970
1992
 
1993
+ gen
1994
+ ("if(l!==undefined){")
1995
+ ("if(r.pos!==c)")
1996
+ ("throw RangeError(\"index out of range\")")
1997
+ ("r.len=l")
1998
+ ("}");
1999
+
1971
2000
  // Field presence
1972
2001
  for (i = 0; i < mtype._fieldsArray.length; ++i) {
1973
2002
  var rfield = mtype._fieldsArray[i];
@@ -5211,6 +5240,9 @@ function parse(source, root, options) {
5211
5240
  }
5212
5241
 
5213
5242
  while (token !== "=") {
5243
+ if (token === null) {
5244
+ throw illegal(token, "end of input");
5245
+ }
5214
5246
  if (token === "(") {
5215
5247
  var parensValue = next();
5216
5248
  skip(")");
@@ -5602,6 +5634,20 @@ Reader.create = create();
5602
5634
 
5603
5635
  Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;
5604
5636
 
5637
+ function readVarint32NearEnd(reader) {
5638
+ // Safely read up to four bytes of a varint32 near the reader limit
5639
+ var value = 0;
5640
+ for (var i = 0; i < 4; ++i) {
5641
+ if (reader.pos >= reader.len)
5642
+ throw indexOutOfRange(reader);
5643
+ var b = reader.buf[reader.pos++];
5644
+ value = (value | (b & 127) << i * 7) >>> 0;
5645
+ if (b < 128)
5646
+ return value;
5647
+ }
5648
+ throw indexOutOfRange(reader);
5649
+ }
5650
+
5605
5651
  /**
5606
5652
  * Reads a varint as an unsigned 32 bit value.
5607
5653
  * @function
@@ -5610,6 +5656,12 @@ Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore ne
5610
5656
  Reader.prototype.uint32 = (function read_uint32_setup() {
5611
5657
  var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)
5612
5658
  return function read_uint32() {
5659
+ if (this.len - this.pos < 5) {
5660
+ if (this.pos >= this.len)
5661
+ throw indexOutOfRange(this);
5662
+ if (this.buf[this.pos] >= 128)
5663
+ return readVarint32NearEnd(this);
5664
+ }
5613
5665
  value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;
5614
5666
  value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;
5615
5667
  value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;
@@ -9237,6 +9289,10 @@ var Message = require(22),
9237
9289
  wrappers[".google.protobuf.Any"] = {
9238
9290
 
9239
9291
  fromObject: function(object, depth) {
9292
+ if (depth === undefined)
9293
+ depth = 0;
9294
+ if (depth > util.recursionLimit)
9295
+ throw Error("max depth exceeded");
9240
9296
 
9241
9297
  // unwrap value type if mapped
9242
9298
  if (object && object["@type"]) {
@@ -9254,7 +9310,7 @@ wrappers[".google.protobuf.Any"] = {
9254
9310
  }
9255
9311
  return this.create({
9256
9312
  type_url: type_url,
9257
- value: type.encode(type.fromObject(object, depth === undefined ? 1 : depth + 1)).finish()
9313
+ value: type.encode(type.fromObject(object, depth + 1)).finish()
9258
9314
  });
9259
9315
  }
9260
9316
  }