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

[2.x cherry-pick] Prevent outbound buffer overwrite during chunking #93

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

prudrabhat
Copy link
Contributor

Description

Problem: For large Assurance events, the way the outbound event is being read and converted to a string can cause un-necessary content being appended to the last chunk. This is because the content is read in to a buffer and converted to a string directly irrespective of the actual bytes read. So if the last chunk of data is smaller than the buffer size the remaining part from the buffer could be included.

Solution: As a solution, modify the reading algorithm to store the number of bytes actually read. Then when creating the string use only the portion of the bytes actually read.

Related Issue

#80

Motivation and Context

feature/v-next was cut before the fix was made. This is a direct cherry-pick from 2.x.
Problem: For large Assurance events, the way the outbound event is being read and converted to a string can cause un-necessary content being appended to the last chunk. This is because the content is read in to a buffer and converted to a string directly irrespective of the actual bytes read. So if the last chunk of data is smaller than the buffer size the remaining part from the buffer could be included.

Solution: As a solution, modify the reading algorithm to store the number of bytes actually read. Then when creating the string use only the portion of the bytes actually read.

How Has This Been Tested?

  • Unit tests
  • Manual tests

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

For large Assurance events, the way the outbound event  is being read
and converted to a string can cause un-necessary content being appended to
the last chunk. This is because the content is read in to a buffer and
converted to a string directly irrespective of the acutal bytes read.
So if the last chunk of data is smaller than the buffer size the remaining
part from the buffer could be included.

As a solution, modify the reading algorithm to store the number of bytes
actually read. Then when creating the string use only the portion of the
bytes actually read.
@prudrabhat
Copy link
Contributor Author

Looks like the circle ci step did not run fir this PR because I have one setup for my branch and it passed - https://app.circleci.com/pipelines/github/prudrabhat/aepsdk-assurance-android/105/workflows/cd6bcdcb-f8b1-4c99-ab12-985ccca30754

@prudrabhat prudrabhat merged commit fda235f into adobe:feature/v-next Mar 1, 2024
2 checks passed
@prudrabhat prudrabhat deleted the cherrypick_2x_fix branch March 5, 2024 22:51
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

Successfully merging this pull request may close these issues.

None yet

2 participants