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);
|
FTPC_SET_LOGGEDIN(session);
|
||||||
session->homerdir = ftpc_rpwd((SESSION)session);
|
session->homerdir = ftpc_rpwd((SESSION)session);
|
||||||
|
if (session->homerdir != NULL)
|
||||||
|
{
|
||||||
session->currdir = strdup(session->homerdir);
|
session->currdir = strdup(session->homerdir);
|
||||||
|
}
|
||||||
|
|
||||||
/* If the user has requested a special start up directory, then change to
|
/* If the user has requested a special start up directory, then change to
|
||||||
* that directory now.
|
* that directory now.
|
||||||
|
@ -85,6 +85,11 @@ int ftpc_mkdir(SESSION handle, FAR const char *path)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ptr = strdup(path);
|
ptr = strdup(path);
|
||||||
|
if (!ptr)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ftpc_stripslash(ptr);
|
ftpc_stripslash(ptr);
|
||||||
|
|
||||||
/* Send the MKD request. The MKD request asks the server to create a new
|
/* 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;
|
int ret;
|
||||||
|
|
||||||
oldcopy = strdup(oldname);
|
oldcopy = strdup(oldname);
|
||||||
|
if (!oldcopy)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ftpc_stripslash(oldcopy);
|
ftpc_stripslash(oldcopy);
|
||||||
|
|
||||||
/* A RNFR request asks the server to begin renaming a file. A typical
|
/* 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;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(oldcopy);
|
||||||
newcopy = strdup(newname);
|
newcopy = strdup(newname);
|
||||||
|
if (!newcopy)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ftpc_stripslash(newcopy);
|
ftpc_stripslash(newcopy);
|
||||||
|
|
||||||
/* A RNTO request asks the server to finish renaming a file. RNTO must
|
/* 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);
|
ret = ftpc_cmd(session, "RNTO %s", newcopy);
|
||||||
|
|
||||||
free(oldcopy);
|
|
||||||
free(newcopy);
|
free(newcopy);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,11 @@ int ftpc_rmdir(SESSION handle, FAR const char *path)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ptr = strdup(path);
|
ptr = strdup(path);
|
||||||
|
if (!ptr)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ftpc_stripslash(ptr);
|
ftpc_stripslash(ptr);
|
||||||
|
|
||||||
/* An RMD request asks the server to remove a directory. A typical server
|
/* 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",
|
ret = ftpc_cmd(session, "TYPE %c",
|
||||||
xfrmode == FTPC_XFRMODE_ASCII ? 'A' : 'I');
|
xfrmode == FTPC_XFRMODE_ASCII ? 'A' : 'I');
|
||||||
UNUSED(ret);
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
session->xfrmode = xfrmode;
|
session->xfrmode = xfrmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user