Skip to content

util.py: Fix TypeError when a received path cannot be resolved - #266

Open
Amadeus-22 wants to merge 2 commits into
linuxmint:masterfrom
Amadeus-22:fix-path-resolve-error
Open

Amadeus-22 wants to merge 2 commits into
linuxmint:masterfrom
Amadeus-22:fix-path-resolve-error

Conversation

@Amadeus-22

Copy link
Copy Markdown
Contributor

Two small fixes in error reporting while receiving files, one commit each.

util.py – In test_resolved_path_safety(), the RuntimeError branch is

raise ReceiveError("Could not resolve path '%s': %s" % str(e))

Two placeholders, one argument. Path.resolve() raises RuntimeError on a symlink loop, which a sender can produce with a symlink entry, so the transfer fails with TypeError: not enough arguments for format string instead of a ReceiveError, and the error reaches the generic handler instead of the ReceiveError one. It now passes (unresolved, str(e)), like the ValueError branch below it.

Checked with a save folder containing top/loop -> loop and test_resolved_path_safety("top/loop/x"):

before: TypeError: not enough arguments for format string
after:  ReceiveError: Could not resolve path '<save>/top/loop/x': Symlink loop from '<save>/top/loop/x'

transfers.py – apply_folder_permissions() logged self.current_path when os.chmod failed, but close_current_file() has already set it to None, so the warning read folder 'None'. It now logs path, the folder being restored.

The RuntimeError branch of test_resolved_path_safety() formatted two
placeholders with one argument, so a symlink loop in a transfer raised
'not enough arguments for format string' instead of a ReceiveError.
apply_folder_permissions() logged self.current_path, which is already
None at that point, instead of the folder being processed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant