netutils/ftpc: add some error checks
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
parent
4a56546811
commit
810398de01
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user