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

[CBSE-6309] Xamarin Android BlobWriteStream writing extra bytes #1120

borrrden opened this issue Jan 24, 2019 · 1 comment


Copy link

commented Jan 24, 2019

When creating a blob, sometimes extra information gets written to the end of the file causing incorrect data.

Library Version


.NET Runtime

Xamarin Android

Operating System / Device Details

Android 8.1

Log Output

Expected behavior

The bytes and length should exactly match the input of the blob after save

Actual behavior

Erroneous data is adding after the end of the blob file

Steps To Reproduce

  1. Create a blob using the stream constructor
  2. Do not access Content
  3. Save the blob into a database via a document
  4. Check the length of the blob and content

Reproduction Project

@borrrden borrrden added this to the Iridium milestone Jan 24, 2019
@borrrden borrrden self-assigned this Jan 24, 2019
@borrrden borrrden changed the title Xamarin Android BlobWriteStream writing extra bytes [CBSE-6309] Xamarin Android BlobWriteStream writing extra bytes Jan 24, 2019

This comment has been minimized.

Copy link
Member Author

commented Jan 24, 2019

This is actually an easy fix. The reason it was never caught in testing is because it was never tested with a stream containing data larger than 8Kb in conjunction with the CopyTo method. The CopyTo method will chunk this and pipe it from a stream 8192 (by default) bytes at a time, and so if the data is not a multiple of 8192 then the mistaken logic in BlobWriteStream will pad zero until the next 8192 byte boundary instead of obeying the count provided from the Write method.

@borrrden borrrden closed this in 46c2b62 Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.