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

Potentially improper use of BinaryReader #1

Open
GrabYourPitchforks opened this issue Mar 4, 2024 · 0 comments
Open

Potentially improper use of BinaryReader #1

GrabYourPitchforks opened this issue Mar 4, 2024 · 0 comments

Comments

@GrabYourPitchforks
Copy link

  1. BinaryReader defaults to Encoding.UTF8, which replaces invalid UTF-8 data with the U+FFFD replacement char. This differs from both the MS-NRBF spec and the existing BinaryFormatter behavior, which requires well-formed UTF-8. Consider creating a UTF8Encoding instance using the public ctor and passing throwOnInvalidBytes: true, then using that for all operations.

  2. BinaryReader.ReadString does not enforce minimal-representation 7-bit encoded integers, though MS-NRBF requires it. Either: (a) reimplement the ReadString helper method yourself to enforce minimal representation; or (b) explicitly document that the reader does not enforce this aspect of the spec, and document the consequences resulting from it.

@GrabYourPitchforks GrabYourPitchforks changed the title BinaryReader comments Potentially improper use of BinaryReader Mar 4, 2024
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