From 832929c15b71841fca99aaa07f9fb5f06f6a111b Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 28 Jan 2016 15:39:06 -0200 Subject: [PATCH] Print parsed command when it is invalid Remove carriage return first before sending command back to the client. --- source/ftp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/ftp.c b/source/ftp.c index 4b4ed87..d6accd1 100644 --- a/source/ftp.c +++ b/source/ftp.c @@ -1234,7 +1234,11 @@ ftp_session_read_command(ftp_session_t *session, /* execute the command */ if(command == NULL) { - ftp_send_response(session, 502, "invalid command\r\n"); + /* remove CRLF from buffer, if exists */ + char *crlf_loc = strstr(buffer, "\r\n"); + if (crlf_loc) + *crlf_loc = '\0'; + ftp_send_response(session, 502, "Invalid command \"%s\"\r\n", buffer); } else if(session->state != COMMAND_STATE) {