Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 - 2007 Pekka Riikonen
+ Copyright (C) 2001 - 2014 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
silc_sftp_close(sftp, session->read_handle, NULL, NULL);
session->read_handle = NULL;
- /* Close the read file descriptor */
+ /* Close the real file descriptor */
silc_file_close(session->fd);
return;
}
silc_sftp_close(sftp, session->read_handle, NULL, NULL);
session->read_handle = NULL;
- /* Close the read file descriptor */
+ /* Close the real file descriptor */
silc_file_close(session->fd);
return;
}
session->fd = silc_file_open(path, O_RDWR | O_CREAT | O_EXCL);
if (session->fd < 0) {
/* Call monitor callback */
+ session->conn->context_type = SILC_ID_CLIENT;
+ session->conn->client_entry = session->client_entry;
session->client->internal->ops->say(session->client, session->conn,
SILC_CLIENT_MESSAGE_ERROR,
"File `%s' open failed: %s",
session->filepath,
strerror(errno));
+ session->conn->context_type = SILC_ID_NONE;
if (session->monitor)
(*session->monitor)(session->client, session->conn,
{
SILC_LOG_DEBUG(("Free session %d", session->session_id));
+ silc_schedule_task_del_by_context(session->client->schedule, session);
+
silc_dlist_del(session->client->internal->ftp_sessions, session);
/* Abort connecting */
/* Add FTP type before SFTP data */
if (status == SILC_STREAM_CAN_WRITE) {
+ silc_buffer_push(buffer, 1);
if (silc_buffer_format(buffer,
SILC_STR_UI_CHAR(1),
SILC_STR_END) < 0)
/* Wrap the connection packet stream */
session->stream = silc_packet_stream_wrap(conn->stream, SILC_PACKET_FTP,
- 0, FALSE,
+ 0, FALSE, 0, NULL, 0, NULL,
silc_client_ftp_coder, session);
if (!session->stream) {
/* Call monitor callback */
silc_client_ftp_connect_completion,
session);
if (!session->listener) {
+ conn->context_type = SILC_ID_CLIENT;
+ conn->client_entry = session->client_entry;
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot create listener for file transfer: "
"%s", strerror(errno));
+ conn->context_type = SILC_ID_NONE;
silc_free(session);
return SILC_CLIENT_FILE_NO_MEMORY;
}
/* Add the listener for the key agreement */
SILC_LOG_DEBUG(("Creating listener for file transfer"));
if (!params || (!params->local_ip && !params->bind_ip)) {
+ session->conn->context_type = SILC_ID_CLIENT;
+ session->conn->client_entry = session->client_entry;
+ session->client->internal->ops->say(session->client, session->conn,
+ SILC_CLIENT_MESSAGE_ERROR,
+ "Cannot create listener for file "
+ "transfer; IP address and/or port "
+ "not provided");
+ session->conn->context_type = SILC_ID_NONE;
silc_free(session);
return SILC_CLIENT_FILE_ERROR;
}
silc_client_ftp_connect_completion,
session);
if (!session->listener) {
+ session->conn->context_type = SILC_ID_CLIENT;
+ session->conn->client_entry = session->client_entry;
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot create listener for file transfer: "
"%s", strerror(errno));
+ session->conn->context_type = SILC_ID_NONE;
silc_free(session);
return SILC_CLIENT_FILE_NO_MEMORY;
}
SilcClientFtpSession session;
SilcClientID remote_id;
SilcClientEntry remote_client;
- SilcKeyAgreementPayload payload;
+ SilcKeyAgreementPayload payload = NULL;
char *hostname;
SilcUInt16 port;
}
out:
+ if (payload)
+ silc_key_agreement_payload_free(payload);
silc_packet_free(packet);
return SILC_FSM_FINISH;
}