|
@@ -553,26 +553,36 @@ err_t lwftp_retr(lwftp_session_t *s)
|
|
|
err_t error;
|
|
|
|
|
|
|
|
|
- if ( (s->control_state!=LWFTP_CLOSED) ||
|
|
|
- !s->settings->remote_path ||
|
|
|
- s->control_pcb ||
|
|
|
- s->data_pcb ||
|
|
|
- !s->settings->user ||
|
|
|
- !s->settings->pass )
|
|
|
- {
|
|
|
- LWIP_DEBUGF(LWFTP_WARNING, ("lwftp:invalid session data\n"));
|
|
|
+ if (s->control_state != LWFTP_CLOSED || s->control_pcb) {
|
|
|
+ s->error = "previous connection is incomplete";
|
|
|
+ return ERR_ARG;
|
|
|
+ }
|
|
|
+ if (!s->settings->remote_path) {
|
|
|
+ s->error = "empty remote path";
|
|
|
return ERR_ARG;
|
|
|
}
|
|
|
+ if (!s->settings->user) {
|
|
|
+ s->error = "empty user name";
|
|
|
+ return ERR_ARG;
|
|
|
+ }
|
|
|
+ if (!s->settings->pass) {
|
|
|
+ s->error = "empty password";
|
|
|
+ return ERR_ARG;
|
|
|
+ }
|
|
|
+ if (s->data_pcb) {
|
|
|
+ lwftp_pcb_close(s->data_pcb);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
s->control_pcb = tcp_new();
|
|
|
if (!s->control_pcb) {
|
|
|
- LWIP_DEBUGF(LWFTP_SERIOUS, ("lwftp:cannot alloc control_pcb (low memory?)\n"));
|
|
|
+ s->error = "cannot alloc control_pcb (low memory?)";
|
|
|
error = ERR_MEM;
|
|
|
goto exit;
|
|
|
}
|
|
|
s->data_pcb = tcp_new();
|
|
|
if (!s->data_pcb) {
|
|
|
- LWIP_DEBUGF(LWFTP_SERIOUS, ("lwftp:cannot alloc data_pcb (low memory?)\n"));
|
|
|
+ s->error = "cannot alloc data_pcb (low memory?)";
|
|
|
error = ERR_MEM;
|
|
|
goto close_pcb;
|
|
|
}
|
|
@@ -585,6 +595,7 @@ err_t lwftp_retr(lwftp_session_t *s)
|
|
|
if ( error == ERR_OK ) goto exit;
|
|
|
|
|
|
LWIP_DEBUGF(LWFTP_SERIOUS, ("lwftp:cannot connect control_pcb (%s)\n", lwip_strerr(error)));
|
|
|
+ s->error = "cannot connet control_pcb";
|
|
|
|
|
|
close_pcb:
|
|
|
|