[GH-ISSUE #841] An incorrect password in FTP will cause an exception to be thrown forever #3601

Closed
opened 2026-03-13 12:10:20 +03:00 by kerem · 4 comments
Owner

Originally created by @itagagaki on GitHub (Jan 24, 2025).
Original GitHub issue: https://github.com/1Remote/1Remote/issues/841

Originally assigned to: @VShawn, @itagagaki on GitHub.

CPU usage remains elevated when authentication fails due to incorrect password in FTP.
An exception continues to be thrown when viewed in the debugger.

Originally created by @itagagaki on GitHub (Jan 24, 2025). Original GitHub issue: https://github.com/1Remote/1Remote/issues/841 Originally assigned to: @VShawn, @itagagaki on GitHub. CPU usage remains elevated when authentication fails due to incorrect password in FTP. An exception continues to be thrown when viewed in the debugger.
kerem 2026-03-13 12:10:20 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@itagagaki commented on GitHub (Jan 25, 2025):

In vmFileTransmitHost.ShowFolder()

github.com/1Remote/1Remote@0aaf606afb/Ui/View/Host/ProtocolHosts/VmFileTransmitHost.cs (L222C1-L265C75)

If the exception is thrown after calling Trans.ListDirectoryItems(), the catch block calls vmFileTransmitHost.ShowFolder() again recursively because CurrentPath is not yet set to path. It will catch another exception. So this goes as an infinite recursive call.

What is the intention of calling ShowFolder() again even after an exception is thrown?

<!-- gh-comment-id:2613859707 --> @itagagaki commented on GitHub (Jan 25, 2025): In `vmFileTransmitHost.ShowFolder()` https://github.com/1Remote/1Remote/blob/0aaf606afb713add0423af13b249f540a3aca7ed/Ui/View/Host/ProtocolHosts/VmFileTransmitHost.cs#L222C1-L265C75 If the exception is thrown after calling `Trans.ListDirectoryItems()`, the catch block calls `vmFileTransmitHost.ShowFolder()` again recursively because `CurrentPath` is not yet set to `path`. It will catch another exception. So this goes as an infinite recursive call. What is the intention of calling `ShowFolder()` again even after an exception is thrown?
Author
Owner

@VShawn commented on GitHub (Jan 26, 2025):

Uh, I don't remember why there was a recursive call in the exception; this code is quite old.

I guess the purpose:

when an error occurred during jumping from directory A to display directory B, thee code in the except block allows the UI to revert to displaying directory A. otherwise, due to the error in ls B, the UI would be blank.

Since I added a check CurrentPath != path before calling ShowFolder(CurrentPath, showIoMessage: false); I believed that infinite recursive calls would not occur.

Add a _lastFailedPath field to record the last failed, which can help avoid recursion.

            catch (Exception e)
            {
                IoMessageLevel = IoMessageLevelError;
                IoMessage = $"ls {CurrentPath}: " + e.Message;
                if (CurrentPath != path && CurrentPath != _lastFailedPath)
                {
                    _lastFailedPath = path;
                    ShowFolder(CurrentPath, showIoMessage: false);
                }
                return;
            }
<!-- gh-comment-id:2614161650 --> @VShawn commented on GitHub (Jan 26, 2025): Uh, I don't remember why there was a recursive call in the exception; this code is quite old. I guess the purpose: when an error occurred during jumping from directory A to display directory B, thee code in the except block allows the UI to revert to displaying directory A. otherwise, due to the error in ls B, the UI would be blank. Since I added a check `CurrentPath != path` before calling `ShowFolder(CurrentPath, showIoMessage: false);` I believed that infinite recursive calls would not occur. Add a `_lastFailedPath` field to record the last failed, which can help avoid recursion. ``` catch (Exception e) { IoMessageLevel = IoMessageLevelError; IoMessage = $"ls {CurrentPath}: " + e.Message; if (CurrentPath != path && CurrentPath != _lastFailedPath) { _lastFailedPath = path; ShowFolder(CurrentPath, showIoMessage: false); } return; } ```
Author
Owner

@itagagaki commented on GitHub (Jan 26, 2025):

I see. I have submitted a patch to solve everything.

<!-- gh-comment-id:2614248351 --> @itagagaki commented on GitHub (Jan 26, 2025): I see. I have submitted a patch to solve everything.
Author
Owner

@VShawn commented on GitHub (Jan 26, 2025):

good

<!-- gh-comment-id:2614448903 --> @VShawn commented on GitHub (Jan 26, 2025): good
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/1Remote#3601
No description provided.