You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/12/13 17:14:52 UTC
[incubator-nuttx-apps] 01/04: netutils/ftpc/ftpc_listdir.c: fix
hardfault when issuing 'ls' before 'login'
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
commit 8f0e87238427662e6d6c07cd5b1f40bedc62106b
Author: Juha Niskanen <ju...@haltian.com>
AuthorDate: Sun Dec 13 17:26:10 2020 +0200
netutils/ftpc/ftpc_listdir.c: fix hardfault when issuing 'ls' before 'login'
Signed-off-by: Juha Niskanen <ju...@haltian.com>
---
netutils/ftpc/ftpc_listdir.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/netutils/ftpc/ftpc_listdir.c b/netutils/ftpc/ftpc_listdir.c
index cf77853..60ff370 100644
--- a/netutils/ftpc/ftpc_listdir.c
+++ b/netutils/ftpc/ftpc_listdir.c
@@ -282,9 +282,21 @@ FAR struct ftpc_dirlist_s *ftpc_listdir(SESSION handle,
int allocsize;
int ret;
+ /* If no remote current directory, we are not logged in. */
+
+ if (!session->currdir)
+ {
+ return NULL;
+ }
+
/* Get the absolute path to the directory */
absrpath = ftpc_absrpath(session, dirpath);
+ if (!absrpath)
+ {
+ return NULL;
+ }
+
ftpc_stripslash(absrpath);
/* Is the directory also the remote current working directory? */
@@ -293,7 +305,13 @@ FAR struct ftpc_dirlist_s *ftpc_listdir(SESSION handle,
/* Create a temporary file to hold the directory listing */
- asprintf(&tmpfname, "%s/TMP%d.dat", CONFIG_FTP_TMPDIR, getpid());
+ ret = asprintf(&tmpfname, "%s/TMP%d.dat", CONFIG_FTP_TMPDIR, getpid());
+ if (ret < 0)
+ {
+ free(absrpath);
+ return NULL;
+ }
+
filestream = fopen(tmpfname, "w+");
if (!filestream)
{