-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Manually implement is_zipfile
#25279
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
Conversation
The default implementation is lenient in that it recognizes a zipfile if the magic number appears anywhere in the archive. So if someone has the bytes `PK\x03\x04` in a tensor, it gets recognized as a zipfile. This implementation only checks the first 4 bytes of the file for the zip magic number. Fixes #25214
zou3519
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs test unless it's hard to repro the bug. However, it sounds like one just needs to serialize a tensor with the magic numbers?
ezyang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Richard said, needs test. Lint failures are real too. Also, shouldn't we be using b'' strings?
|
|
The default implementation is lenient in that it recognizes a zipfile if the magic number appears anywhere in the archive. So if someone has the bytes
PK\x03\x04in a tensor, it gets recognized as a zipfile. See https://bugs.python.org/issue28494This implementation only checks the first 4 bytes of the file for the zip magic number. We could also copy python/cpython#5053 fix, but that seems like overkill.
Fixes #25214
Differential Revision: D17102516