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

Fixed rmdir operation with recursion on non-existent directory #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Marv-CZ
Copy link

@Marv-CZ Marv-CZ commented Dec 19, 2020

When you call rmdir() with recursive=true on a non-existent directory it causes:

TypeError: Cannot read property '0' of undefined
at deleteNextEntry (/opt/noderedftp/lib/node_modules/node-red/nodes/extra/ftp/node_modules/@icetee/ftp/lib/connection.js:808:21)
at /opt/noderedftp/lib/node_modules/node-red/nodes/extra/ftp/node_modules/@icetee/ftp/lib/connection.js:830:5
at final (/opt/noderedftp/lib/node_modules/node-red/nodes/extra/ftp/node_modules/@icetee/ftp/lib/connection.js:515:11)
at Object.cb (/opt/noderedftp/lib/node_modules/node-red/nodes/extra/ftp/node_modules/@icetee/ftp/lib/connection.js:552:11)

rmdir() calls list() which returns "No such file or directory" string instead a error and rmdir() tries to use it as a dir item.

I have replaced list() with listSafe() which is able to return the error, but it has bug too. It doesn't test missing optional arguments. So this patch also solves this issue.

@Marv-CZ
Copy link
Author

Marv-CZ commented Dec 19, 2020

I found out it's not general problem, but only ftpd server from busybox which I used for testing.

@Marv-CZ Marv-CZ changed the title Fixed rmdir operation with recursion on nonexist directory Fixed rmdir operation with recursion on non-existent directory Dec 19, 2020
@Marv-CZ
Copy link
Author

Marv-CZ commented Dec 19, 2020

For non-existent dirname:

BusyBox ftpd
LIST dirname returns data "dirname: No such file or directory" and "226 Transfer complete"
list('dirname', cb) returns [ 'dirname: No such file or directory' ]
rmdir('dirname', true, cb) produces TypeError

Pure-FTPD
LIST dirname returns empty data and "226 0 matches total"
list('dirname', cb) returns []
rmdir('dirname', true, cb) returns error

ProFTPD
LIST dirname returns "450 dirname: No such file or directory"
list('dirname', cb) returns error with message "dirname: No such file or directory"
rmdir('dirname', true, cb) returns error

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