{
int err;
+ if (response)
+ *response = NULL;
+
if ((err = ffurl_write(s->conn_control, command, strlen(command))) < 0)
return err;
if (!err)
static const char *enable_utf8_command = "OPTS UTF8 ON\r\n";
static const int feat_codes[] = {211, 0};
static const int opts_codes[] = {200, 451};
- char *feat;
+ char *feat = NULL;
if (ftp_send_command(s, feat_command, feat_codes, &feat) == 211) {
if (av_stristr(feat, "UTF8"))
ftp_send_command(s, enable_utf8_command, opts_codes, NULL);
}
+ av_freep(&feat);
+
return 0;
}
static int ftp_connect_control_connection(URLContext *h)
{
- char buf[CONTROL_BUFFER_SIZE], opts_format[20], *response = NULL;
+ char buf[CONTROL_BUFFER_SIZE], *response = NULL;
int err;
AVDictionary *opts = NULL;
FTPContext *s = h->priv_data;
ff_url_join(buf, sizeof(buf), "tcp", NULL,
s->hostname, s->server_control_port, NULL);
if (s->rw_timeout != -1) {
- snprintf(opts_format, sizeof(opts_format), "%d", s->rw_timeout);
- av_dict_set(&opts, "timeout", opts_format, 0);
+ av_dict_set_int(&opts, "timeout", s->rw_timeout, 0);
} /* if option is not given, don't pass it and let tcp use its own default */
err = ffurl_open(&s->conn_control, buf, AVIO_FLAG_READ_WRITE,
&h->interrupt_callback, &opts);
static int ftp_connect_data_connection(URLContext *h)
{
int err;
- char buf[CONTROL_BUFFER_SIZE], opts_format[20];
+ char buf[CONTROL_BUFFER_SIZE];
AVDictionary *opts = NULL;
FTPContext *s = h->priv_data;
/* Open data connection */
ff_url_join(buf, sizeof(buf), "tcp", NULL, s->hostname, s->server_data_port, NULL);
if (s->rw_timeout != -1) {
- snprintf(opts_format, sizeof(opts_format), "%d", s->rw_timeout);
- av_dict_set(&opts, "timeout", opts_format, 0);
+ av_dict_set_int(&opts, "timeout", s->rw_timeout, 0);
} /* if option is not given, don't pass it and let tcp use its own default */
err = ffurl_open(&s->conn_data, buf, h->flags,
&h->interrupt_callback, &opts);