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

GFile S3 reader may corrupt files containing multibyte characters or CR/LF #2839

Open
davidsoergel opened this issue Oct 25, 2019 · 1 comment

Comments

@davidsoergel
Copy link
Member

davidsoergel commented Oct 25, 2019

In our stub GFile implementation, the S3 reader obtains chunks of n bytes and then decodes them as strings. This risks corrupting data or at least throwing decoding errors, because the byte chunk may end in the middle of a multibyte character (and correspondingly, the next chunk would begin in the middle of that character).

Thus the chunks cannot be decoded independently. Any partial character must be detected and removed from the end of each chunk, and prepended to the subsequent chunk before decoding.

CRLF (\r\n) is effectively a multibyte character in this context, because Python always "decodes" it to just \n.

See

# TODO(orionr): This endpoint risks splitting a multi-byte

(Followup to #2791 and #2777)

@davidsoergel
Copy link
Member Author

FYI @orionr, @sanekmelnikov, @natalialunova, @lanpa. I can't actually assign you here but please feel free to send a fix if you like. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants