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

Fix extract_zipped_paths infinite loop when provided invalid unc path #5851

Merged
merged 1 commit into from Aug 3, 2021

Conversation

tl-hbk
Copy link
Contributor

@tl-hbk tl-hbk commented Jun 30, 2021

Fixes #5850

@tl-hbk tl-hbk marked this pull request as ready for review June 30, 2021 21:30
@@ -245,6 +245,9 @@ def extract_zipped_paths(path):
archive, member = os.path.split(path)
while archive and not os.path.exists(archive):
archive, prefix = os.path.split(archive)
if not prefix:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explains why, but the code isn't clear as to what's happening or why this fixes the infinite loop. For example, a far superior comment might be:

# If we don't check for an empty prefix after the split (in other words, archive = / before and after the split), we _can_ end up in an infinite loop on a rare corner case affecting a small number of users

This comment explains the conditions, why we care (it affects users), and the risk to making a change (if we break this again, we may not find out about it quickly)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, I've updated the comment.

@sigmavirus24 sigmavirus24 merged commit d8829f9 into psf:master Aug 3, 2021
@nateprewitt nateprewitt added this to the 2.27.0 milestone Sep 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite loop when verify is invalid UNC path
3 participants