diff --git a/netutils/ftpc/ftpc_login.c b/netutils/ftpc/ftpc_login.c index 8f21309af..6f9f53472 100644 --- a/netutils/ftpc/ftpc_login.c +++ b/netutils/ftpc/ftpc_login.c @@ -187,7 +187,10 @@ int ftpc_relogin(FAR struct ftpc_session_s *session) FTPC_SET_LOGGEDIN(session); session->homerdir = ftpc_rpwd((SESSION)session); - session->currdir = strdup(session->homerdir); + if (session->homerdir != NULL) + { + session->currdir = strdup(session->homerdir); + } /* If the user has requested a special start up directory, then change to * that directory now. diff --git a/netutils/ftpc/ftpc_mkdir.c b/netutils/ftpc/ftpc_mkdir.c index 27981b48f..bd32121c3 100644 --- a/netutils/ftpc/ftpc_mkdir.c +++ b/netutils/ftpc/ftpc_mkdir.c @@ -85,6 +85,11 @@ int ftpc_mkdir(SESSION handle, FAR const char *path) int ret; ptr = strdup(path); + if (!ptr) + { + return ERROR; + } + ftpc_stripslash(ptr); /* Send the MKD request. The MKD request asks the server to create a new diff --git a/netutils/ftpc/ftpc_rename.c b/netutils/ftpc/ftpc_rename.c index ec8aae8b7..c5d735a7a 100644 --- a/netutils/ftpc/ftpc_rename.c +++ b/netutils/ftpc/ftpc_rename.c @@ -86,6 +86,11 @@ int ftpc_rename(SESSION handle, FAR const char *oldname, FAR const char *newname int ret; oldcopy = strdup(oldname); + if (!oldcopy) + { + return ERROR; + } + ftpc_stripslash(oldcopy); /* A RNFR request asks the server to begin renaming a file. A typical @@ -107,7 +112,13 @@ int ftpc_rename(SESSION handle, FAR const char *oldname, FAR const char *newname return ERROR; } + free(oldcopy); newcopy = strdup(newname); + if (!newcopy) + { + return ERROR; + } + ftpc_stripslash(newcopy); /* A RNTO request asks the server to finish renaming a file. RNTO must @@ -128,7 +139,6 @@ int ftpc_rename(SESSION handle, FAR const char *oldname, FAR const char *newname ret = ftpc_cmd(session, "RNTO %s", newcopy); - free(oldcopy); free(newcopy); return ret; } diff --git a/netutils/ftpc/ftpc_rmdir.c b/netutils/ftpc/ftpc_rmdir.c index 4cf5cdf5b..5f78ef2b3 100644 --- a/netutils/ftpc/ftpc_rmdir.c +++ b/netutils/ftpc/ftpc_rmdir.c @@ -83,6 +83,11 @@ int ftpc_rmdir(SESSION handle, FAR const char *path) int ret; ptr = strdup(path); + if (!ptr) + { + return ERROR; + } + ftpc_stripslash(ptr); /* An RMD request asks the server to remove a directory. A typical server diff --git a/netutils/ftpc/ftpc_transfer.c b/netutils/ftpc/ftpc_transfer.c index 72cbace11..b983a13fb 100644 --- a/netutils/ftpc/ftpc_transfer.c +++ b/netutils/ftpc/ftpc_transfer.c @@ -557,7 +557,11 @@ int ftpc_xfrmode(struct ftpc_session_s *session, uint8_t xfrmode) ret = ftpc_cmd(session, "TYPE %c", xfrmode == FTPC_XFRMODE_ASCII ? 'A' : 'I'); - UNUSED(ret); + if (ret < 0) + { + return ERROR; + } + session->xfrmode = xfrmode; }