Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The decoding/fromBuffer fails and crashes with this "complex" structure #64

Open
ItzSiL3Nce opened this issue Oct 8, 2024 · 0 comments

Comments

@ItzSiL3Nce
Copy link

ItzSiL3Nce commented Oct 8, 2024

Given this structure:

const PacketFromRestructure = new r.Struct({
  i: r.uint32,
  a: new r.Array(r.uint32),
  sub: new r.Struct({
    subI: r.uint32,
    subArray: new r.Array(r.uint32)
  })
})

The encoding/toBuffer part works fine:

const encoded = PacketFromRestructure.toBuffer({
  i: 0,
  a: [1, 2],
  sub: { subArray: [1, 2, 3], subI: 2 }
})

But its decoding/fromBuffer fails and crashes:

const decoded = PacketFromRestructure.fromBuffer(encoded)

The crash:

node_modules\restructure\dist\src\DecodeStream.js:72
      const ret = this.view[key](this.pos, false);
                                ^
RangeError: Offset is outside the bounds of the DataView
    at DataView.prototype.getUint32 (<anonymous>)
    at $8ae20583b93e4933$export$c18b354bac7948e9.<computed> [as readUInt32BE]
    ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant