This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new aaa950fae netutils/ftpd: Do not terminate connection if CWD fails
aaa950fae is described below
commit aaa950faeebfa616d024338babeb01ccb9af8b96
Author: Petro Karashchenko <[email protected]>
AuthorDate: Sun Apr 3 14:17:20 2022 +0200
netutils/ftpd: Do not terminate connection if CWD fails
Signed-off-by: Petro Karashchenko <[email protected]>
---
netutils/ftpd/ftpd.c | 24 ++++++++++--------------
netutils/ftpd/ftpd.h | 12 ++++++------
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/netutils/ftpd/ftpd.c b/netutils/ftpd/ftpd.c
index 94398b4cb..0fc840d64 100644
--- a/netutils/ftpd/ftpd.c
+++ b/netutils/ftpd/ftpd.c
@@ -484,7 +484,7 @@ ftpd_account_search_user(FAR struct ftpd_session_s *session,
FAR const char *user)
{
FAR struct ftpd_account_s *newaccount = NULL;
- FAR struct ftpd_account_s *account;
+ const FAR struct ftpd_account_s *account;
uint8_t accountflags;
account = session->head;
@@ -1656,24 +1656,20 @@ static int ftpd_changedir(FAR struct ftpd_session_s
*session,
ret = stat(abspath, &st);
if (ret < 0)
{
- ret = -errno;
-
free(workpath);
free(abspath);
- ftpd_response(session->cmd.sd, session->txtimeout,
- g_respfmt2, 550, ' ', rempath,
- ": No such file or directory");
- return ret;
+ return ftpd_response(session->cmd.sd, session->txtimeout,
+ g_respfmt2, 550, ' ', rempath,
+ ": No such file or directory");
}
if (S_ISDIR(st.st_mode) == 0)
{
free(workpath);
free(abspath);
- ftpd_response(session->cmd.sd, session->txtimeout,
- g_respfmt2, 550, ' ', rempath,
- ": No such file or directory");
- return -ENOTDIR;
+ return ftpd_response(session->cmd.sd, session->txtimeout,
+ g_respfmt2, 550, ' ', rempath,
+ ": No such file or directory");
}
free(abspath);
@@ -2064,8 +2060,8 @@ static int ftpd_stream(FAR struct ftpd_session_s
*session, int cmdtype)
wrbytes, errval);
ftpd_response(session->cmd.sd, session->txtimeout,
g_respfmt1, 550, ' ', "Data send error !");
- ret = -errval;
- break;
+ ret = -errval;
+ break;
}
/* Get the next file offset */
@@ -4145,7 +4141,7 @@ static FAR void *ftpd_worker(FAR void *arg)
/* Send the welcoming message */
ret = ftpd_response(session->cmd.sd, session->txtimeout,
- g_respfmt1, 220, ' ', CONFIG_FTPD_SERVERID);
+ g_respfmt1, 220, ' ', CONFIG_FTPD_SERVERID);
if (ret < 0)
{
nerr("ERROR: ftpd_response() failed: %d\n", ret);
diff --git a/netutils/ftpd/ftpd.h b/netutils/ftpd/ftpd.h
index b574254db..a54469f20 100644
--- a/netutils/ftpd/ftpd.h
+++ b/netutils/ftpd/ftpd.h
@@ -118,12 +118,12 @@ struct ftpd_stream_s
struct ftpd_session_s
{
- FAR struct ftpd_server_s *server;
- FAR struct ftpd_account_s *head;
- bool loggedin;
- uint8_t flags; /* See TPD_SESSIONFLAG_* definitions */
- int rxtimeout;
- int txtimeout;
+ const FAR struct ftpd_server_s *server;
+ const FAR struct ftpd_account_s *head;
+ bool loggedin;
+ uint8_t flags; /* See TPD_SESSIONFLAG_*
definitions */
+ int rxtimeout;
+ int txtimeout;
/* Command */