adobe / aepsdk-assurance-android

Adobe Experience Platform Assurance SDK
Apache License 2.0
2 stars 5 forks source link

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

Closed prudrabhat closed 8 months ago

prudrabhat commented 8 months ago

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

https://github.com/adobe/aepsdk-assurance-android/pull/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?

Screenshots (if appropriate):

Types of changes

Checklist:

prudrabhat commented 8 months ago

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