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

"Offset is outside the bounds of the DataView" for Data and Event PDUs #8

Open
sgogos1 opened this issue Mar 4, 2021 · 3 comments
Open

Comments

@sgogos1
Copy link

sgogos1 commented Mar 4, 2021

Repeatedly receiving the error:

"Offset is outside the bounds of the DataView" when trying to unpack Data and Event PDUs that have a fixed or variable datum attached to them.

Is there a fix to this that I'm unaware of currently?

@sgogos1
Copy link
Author

sgogos1 commented Mar 4, 2021

Made a really dirty fix (not proud of it) and added a conditional statement in dis.InputStream.readByte that solved the "Offset is outside the bounds of the DataView" error I was catching.

   dis.InputStream.prototype.readByte = function()
    {
        if (this.currentPosition !== this.dataView.byteLength){
          var data = this.dataView.getInt8(this.currentPosition);
          this.currentPosition = this.currentPosition + 1;
          return data;
        }
    }

When unpackaging a DataPDU that contained a Variable Datum, the function was getting properly called while iterating through the DataView (e.g. bytelength === 176). But when it completed the last element (currentPosition === 175), it would iterate up currentPosition again (currentPosition === 176) and then call readByte again. With zero-indexing in mind, there was nothing there since the last element in the DataView was 175.

I might be missing something in my execution (outside of this fix) and am happy to know if there's a cleaner way to solve this issue. This stopped me from getting errors and returned the data pdu though.

@leif81
Copy link
Member

leif81 commented Mar 5, 2021

Thanks for the report @sgogos1

Can you share a wireshark capture with the pdus that are causing the issue?

@sgogos1
Copy link
Author

sgogos1 commented Mar 5, 2021

@leif81 Unfortunately due to the nature of my work (this is a work project) I can't share the data as it'd violate my employment policy. Is there another way I can help you in trying to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants