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

Incomplete implementation in SanitizedFile#read can lead to infinite loop #2770

Closed
mshibuya opened this issue Dec 31, 2024 · 0 comments
Closed
Assignees
Labels

Comments

@mshibuya
Copy link
Member

To address the point reported by #1959, CarrierWave::SanitizedFile#read was changed to accept optional arguments in 9096459. It didn't come with full features that are expected for IO#read, to cope with the existing implementation that normally reads all the content at once.

But it turned out that the incompleteness is very harmful. When combined with a legitimate implementation of chunked reading like this one, it results in infinite loop because SanitizedFile#read keeps returning the same content endlessly.
https://github.com/mongoid/mongoid-grid_fs/blob/878393f1ba990909c4519641926d3f8d77230407/lib/mongoid/grid_fs.rb#L465-L467

I found this when I was working on an attempt of making carrierwave-mongoid support carrierwave 3.x, and it was very hard to debug. We should have a proper fix for this.

@mshibuya mshibuya added the bug label Dec 31, 2024
@mshibuya mshibuya self-assigned this Dec 31, 2024
@mshibuya mshibuya changed the title Incomplete implementation in SanitizedFile#read leads to infinite loop Incomplete implementation in SanitizedFile#read can lead to infinite loop Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant