Skip to content

Fix extract_zipped_paths infinite loop when provided invalid unc path#5851

Merged
sigmavirus24 merged 1 commit intopsf:masterfrom
tl-hbk:fix_extract_zipped_paths
Aug 3, 2021
Merged

Fix extract_zipped_paths infinite loop when provided invalid unc path#5851
sigmavirus24 merged 1 commit intopsf:masterfrom
tl-hbk:fix_extract_zipped_paths

Conversation

@tl-hbk
Copy link
Copy Markdown
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
Comment thread requests/utils.py
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
Copy Markdown
Contributor

@sigmavirus24 sigmavirus24 Jul 6, 2021

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
Copy Markdown
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.

@tl-hbk tl-hbk force-pushed the fix_extract_zipped_paths branch from ad17472 to 3d6c95b Compare August 2, 2021 17:44
@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