diff --git a/MakeFileGeneric b/MakeFileGeneric index c2f3944..19044e1 100644 --- a/MakeFileGeneric +++ b/MakeFileGeneric @@ -3,6 +3,9 @@ CC=gcc OUTPATH=./build/ SOURCE_MODULES_PATH=./library/ + +#FOR DEBUG PURPOSE +#CFLAGS=-c -Wall -I. -g -O0 CFLAGS=-c -Wall -I. OPTIMIZATION=-O3 HEADERS=-I @@ -61,4 +64,4 @@ ftpServer.o: clean: @rm -rf $(LIBPATH)*.o $(OUTPATH)uFTP - @echo "Clean ok" \ No newline at end of file + @echo "Clean ok" diff --git a/build/Debug/GNU-Linux/ftpCommandElaborate.o b/build/Debug/GNU-Linux/ftpCommandElaborate.o index faccffc..bd9195e 100644 Binary files a/build/Debug/GNU-Linux/ftpCommandElaborate.o and b/build/Debug/GNU-Linux/ftpCommandElaborate.o differ diff --git a/build/Debug/GNU-Linux/ftpServer.o b/build/Debug/GNU-Linux/ftpServer.o index fb60985..ec6abe0 100644 Binary files a/build/Debug/GNU-Linux/ftpServer.o and b/build/Debug/GNU-Linux/ftpServer.o differ diff --git a/build/modules/configRead.o b/build/modules/configRead.o index b91b520..ce2895a 100644 Binary files a/build/modules/configRead.o and b/build/modules/configRead.o differ diff --git a/build/modules/ftpCommandElaborate.o b/build/modules/ftpCommandElaborate.o index 91d4cea..65341d1 100644 Binary files a/build/modules/ftpCommandElaborate.o and b/build/modules/ftpCommandElaborate.o differ diff --git a/build/modules/ftpServer.o b/build/modules/ftpServer.o index 9b9cb7a..fd05f0f 100644 Binary files a/build/modules/ftpServer.o and b/build/modules/ftpServer.o differ diff --git a/build/uFTP b/build/uFTP index 025b567..afdda73 100755 Binary files a/build/uFTP and b/build/uFTP differ diff --git a/dist/Debug/GNU-Linux/uftp b/dist/Debug/GNU-Linux/uftp index 5234a67..c62b2b6 100755 Binary files a/dist/Debug/GNU-Linux/uftp and b/dist/Debug/GNU-Linux/uftp differ diff --git a/ftpCommandElaborate.c b/ftpCommandElaborate.c index 46a9654..bf0c4dc 100644 --- a/ftpCommandElaborate.c +++ b/ftpCommandElaborate.c @@ -142,7 +142,7 @@ int parseCommandPass(ftpDataType * data, int socketId) { if (((loginFailsDataType *) data->loginFailsVector.Data[searchPosition])->failureNumbers >= data->ftpParameters.maximumUserAndPassowrdLoginTries) { - //printf("\n TOO MANY LOGIN FAILS! \n"); + printf("\n TOO MANY LOGIN FAILS! \n"); data->clients[socketId].closeTheClient = 1; returnCode = dprintf(data->clients[socketId].socketDescriptor, "430 Too many login failure detected, your ip will be blacklisted for 5 minutes\r\n"); if (returnCode <= 0) return FTP_COMMAND_PROCESSED_WRITE_ERROR; @@ -220,6 +220,9 @@ int parseCommandAuth(clientDataType *theClientData) returnCode = dprintf(theClientData->socketDescriptor, "502 Security extensions not implemented.\r\n"); if (returnCode <= 0) return FTP_COMMAND_PROCESSED_WRITE_ERROR; + + //client -> AUTH TLS + //server -> 234 AUTH TLS OK. return FTP_COMMAND_PROCESSED; } @@ -823,6 +826,7 @@ int parseCommandQuit(ftpDataType * data, int socketId) return FTP_COMMAND_PROCESSED_WRITE_ERROR; data->clients[socketId].closeTheClient = 1; + printf("\n Closing the client quit received"); return FTP_COMMAND_PROCESSED; } diff --git a/ftpServer.c b/ftpServer.c index 4308553..1c45ba0 100644 --- a/ftpServer.c +++ b/ftpServer.c @@ -90,6 +90,7 @@ void *connectionWorkerHandle(void * socketId) if (ftpData.clients[theSocketId].workerData.passiveListeningSocket == -1) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 1"); pthread_exit(NULL); } @@ -100,6 +101,7 @@ void *connectionWorkerHandle(void * socketId) if (returnCode <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 2"); pthread_exit(NULL); } @@ -111,6 +113,7 @@ void *connectionWorkerHandle(void * socketId) else { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 3"); pthread_exit(NULL); } } @@ -122,6 +125,7 @@ void *connectionWorkerHandle(void * socketId) if (ftpData.clients[theSocketId].workerData.socketConnection < 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 4"); pthread_exit(NULL); } @@ -130,6 +134,7 @@ void *connectionWorkerHandle(void * socketId) if (returnCode <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 5"); pthread_exit(NULL); } @@ -172,6 +177,7 @@ void *connectionWorkerHandle(void * socketId) if (returnCode <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 6"); pthread_exit(NULL); } @@ -183,6 +189,7 @@ void *connectionWorkerHandle(void * socketId) if (returnCode <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 7"); pthread_exit(NULL); } @@ -217,6 +224,7 @@ void *connectionWorkerHandle(void * socketId) if (returnCode <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 8"); pthread_exit(NULL); } @@ -238,6 +246,7 @@ void *connectionWorkerHandle(void * socketId) if (returnCode <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 8"); pthread_exit(NULL); } @@ -245,6 +254,7 @@ void *connectionWorkerHandle(void * socketId) if (returnCode <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 9"); pthread_exit(NULL); } @@ -252,6 +262,7 @@ void *connectionWorkerHandle(void * socketId) if (returnCode <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 10"); pthread_exit(NULL); } @@ -266,6 +277,7 @@ void *connectionWorkerHandle(void * socketId) if (writeReturn <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 11"); pthread_exit(NULL); } @@ -280,6 +292,7 @@ void *connectionWorkerHandle(void * socketId) if (writeReturn <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 12"); pthread_exit(NULL); } break; @@ -290,6 +303,7 @@ void *connectionWorkerHandle(void * socketId) if (writeReturn <= 0) { ftpData.clients[theSocketId].closeTheClient = 1; + printf("\n Closing the client 13"); pthread_exit(NULL); } break; @@ -427,10 +441,12 @@ void runFtpServer(void) else if (commandProcessStatus == FTP_COMMAND_PROCESSED) { ftpData.clients[processingSock].lastActivityTimeStamp = (int)time(NULL); + } else if (commandProcessStatus == FTP_COMMAND_PROCESSED_WRITE_ERROR) { ftpData.clients[processingSock].closeTheClient = 1; + printf("\n Write error, closing the client!"); } } } @@ -441,7 +457,10 @@ void runFtpServer(void) ftpData.clients[processingSock].commandIndex = 0; memset(ftpData.clients[processingSock].theCommandReceived, 0, CLIENT_COMMAND_STRING_SIZE); returnCode = dprintf(ftpData.clients[processingSock].socketDescriptor, "500 Unknown command\r\n"); - if (returnCode <= 0) ftpData.clients[processingSock].closeTheClient = 1; + if (returnCode <= 0) + ftpData.clients[processingSock].closeTheClient = 1; + + printf("\n Command too long closing the client."); break; } } diff --git a/library/configRead.c b/library/configRead.c index c0dfb31..e584bfd 100644 --- a/library/configRead.c +++ b/library/configRead.c @@ -334,6 +334,10 @@ static int readConfigurationFile(char *path, DYNV_VectorGenericDataType *paramet parametersVector->PushBack(parametersVector, ¶meter, sizeof(parameter_DataType)); } + if (theFileSize > 0) { + free(theFileContent); + } + return 1; }