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

Avoid holding onto the buffer when parsing unknown length-delimited fields #863

Merged
merged 5 commits into from
Aug 2, 2023

Commits on Jul 29, 2023

  1. Avoid holding onto the buffer when parsing unknown length-delimited f…

    …ields
    
    Currently unknown field set parser stores length-delimited fields as
    views of the input buffer. This has a few issues:
    
    - It's inconsistent with the known-field parsing where we copy `bytes`
      fields.
    
    - A single unknown length-delimited field can cause keeping a large
      input buffer alive.
    
    - Because the caller is free to modify the input buffer, this
      implementation does not allow freezing an unknown field set.
    
      (This can also be fixed by copying the length-delimited fields when
      freezing.)
    
    - Even when the parsed message is not frozen this aliasing can cause
      bugs as it's not documented. Even if we documented it, it would
      probably be a footgun.
    
    - Most importantly, this can cause segfaults or worse when the input
      buffer is passed from e.g. C++ or C as a `Uint8List`, and the caller
      frees the buffer after parsing while the message is still in use.
    
    This PR updates length-delimited unknown field parsing to copy the bytes
    before storing the field in `UnknownFieldSet`.
    osa1 committed Jul 29, 2023
    Configuration menu
    Copy the full SHA
    83d4254 View commit details
    Browse the repository at this point in the history
  2. Fix lint

    osa1 committed Jul 29, 2023
    Configuration menu
    Copy the full SHA
    5f3fa60 View commit details
    Browse the repository at this point in the history
  3. Update CHANGELOG

    osa1 committed Jul 29, 2023
    Configuration menu
    Copy the full SHA
    63d5d20 View commit details
    Browse the repository at this point in the history

Commits on Jul 31, 2023

  1. Configuration menu
    Copy the full SHA
    08a4a99 View commit details
    Browse the repository at this point in the history

Commits on Aug 2, 2023

  1. Configuration menu
    Copy the full SHA
    7f06f9d View commit details
    Browse the repository at this point in the history