From dcfa0d12e32a08cd522501de7a01ead818af62ac Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 22 Mar 2017 11:11:11 +1000 Subject: [PATCH] fix bug in passive mode --- utils/magiftpd/magiftpd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/magiftpd/magiftpd.c b/utils/magiftpd/magiftpd.c index 3206f82..182f0f7 100644 --- a/utils/magiftpd/magiftpd.c +++ b/utils/magiftpd/magiftpd.c @@ -210,6 +210,8 @@ int open_tcp_connection(struct ftpserver *cfg, struct ftpclient *client) { return 0; } if (connect(client->data_socket, (struct sockaddr *) &servaddr, sizeof(struct sockaddr)) == -1) { + memset(client->data_ip, 0, 20); + client->data_port = -1; fprintf(stderr, "Error connecting to client\n"); return 0; } @@ -320,7 +322,7 @@ void handle_PASV(struct ftpserver *cfg, struct ftpclient *client) { } struct sockaddr_in server; server.sin_family = AF_INET; - server.sin_addr.s_addr = inet_addr(client->ip); + server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(0); if (bind(client->data_srv_socket, (struct sockaddr*) &server, sizeof(struct sockaddr)) < 0) {