Some memory leak fix

This commit is contained in:
Ugo Cirmignani
2018-11-29 22:30:48 +01:00
parent f439ba603c
commit 228eb8d222
45 changed files with 45 additions and 183 deletions

View File

@ -5,8 +5,8 @@ OUTPATH=./build/
SOURCE_MODULES_PATH=./library/
#FOR DEBUG PURPOSE
#CFLAGS=-c -Wall -I. -g -O0
CFLAGS=-c -Wall -I.
CFLAGS=-c -Wall -I. -g -O0
#CFLAGS=-c -Wall -I.
OPTIMIZATION=-O3
HEADERS=-I
LIBPATH=./build/modules/

Binary file not shown.

Binary file not shown.

View File

@ -1,23 +0,0 @@
build/Debug/GNU-Linux/library/configRead.o: library/configRead.c \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h library/configRead.h library/dynamicVectors.h \
library/../ftpData.h library/../library/dynamicVectors.h \
library/fileManagement.h library/daemon.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/configRead.h:
library/dynamicVectors.h:
library/../ftpData.h:
library/../library/dynamicVectors.h:
library/fileManagement.h:
library/daemon.h:

View File

@ -1,16 +0,0 @@
build/Debug/GNU-Linux/library/connection.o: library/connection.c \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h library/../ftpData.h \
library/../library/dynamicVectors.h library/connection.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/../ftpData.h:
library/../library/dynamicVectors.h:
library/connection.h:

View File

@ -1,11 +0,0 @@
build/Debug/GNU-Linux/library/daemon.o: library/daemon.c \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h library/fileManagement.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/fileManagement.h:

View File

@ -1,11 +0,0 @@
build/Debug/GNU-Linux/library/dynamicVectors.o: library/dynamicVectors.c \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h library/dynamicVectors.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/dynamicVectors.h:

View File

@ -1,14 +0,0 @@
build/Debug/GNU-Linux/library/fileManagement.o: library/fileManagement.c \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:

View File

@ -1,11 +0,0 @@
build/Debug/GNU-Linux/library/logFunctions.o: library/logFunctions.c \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h library/logFunctions.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/logFunctions.h:

View File

@ -1,11 +0,0 @@
build/Debug/GNU-Linux/library/openSsl.o: library/openSsl.c \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h library/openSsl.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/openSsl.h:

View File

@ -1,11 +0,0 @@
build/Debug/GNU-Linux/library/signals.o: library/signals.c \
library/dynamicVectors.h library/fileManagement.h \
library/dynamicVectors.h library/../ftpServer.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/../ftpServer.h:

Binary file not shown.

View File

@ -1,10 +0,0 @@
build/Debug/GNU-Linux/uFTP.o: uFTP.c library/dynamicVectors.h \
library/fileManagement.h library/dynamicVectors.h ftpServer.h
library/dynamicVectors.h:
library/fileManagement.h:
library/dynamicVectors.h:
ftpServer.h:

View File

@ -1,22 +0,0 @@
build/Release/GNU-Linux/ftpCommandElaborate.o: ftpCommandElaborate.c \
ftpData.h library/dynamicVectors.h ftpServer.h library/logFunctions.h \
library/fileManagement.h library/dynamicVectors.h library/configRead.h \
library/../ftpData.h ftpCommandsElaborate.h
ftpData.h:
library/dynamicVectors.h:
ftpServer.h:
library/logFunctions.h:
library/fileManagement.h:
library/dynamicVectors.h:
library/configRead.h:
library/../ftpData.h:
ftpCommandsElaborate.h:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
dist/Debug/GNU-Linux/uftp vendored Executable file

Binary file not shown.

View File

@ -597,7 +597,7 @@ void resetWorkerData(workerDataType *workerData, int isInitialization)
void resetClientData(clientDataType *clientData, int isInitialization)
{
if (isInitialization != 0)
if (isInitialization != 1)
{
if (clientData->workerData.threadIsAlive == 1)
{
@ -607,7 +607,7 @@ void resetClientData(clientDataType *clientData, int isInitialization)
}
else
{
void *pReturn;
void *pReturn = NULL;
pthread_join(clientData->workerData.workerThread, &pReturn);
}
}

View File

@ -252,6 +252,7 @@ void resetWorkerData(workerDataType *pasvData, int isInitialization);
void resetClientData(clientDataType *clientData, int isInitialization);
int compareStringCaseInsensitive(char *stringIn, char* stringRef, int stringLenght);
int isCharInString(char *theString, int stringLen, char theChar);
void destroyConfigurationVectorElement(void * data);
#ifdef __cplusplus
}
#endif

View File

@ -328,9 +328,6 @@ void runFtpServer(void)
{
printf("\nHello uFTP server v%s starting..\n", UFTP_SERVER_VERSION);
/* Needed for Select*/
static int processingSock = 0, returnCode = 0;

View File

@ -40,6 +40,12 @@ static int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_Ve
static int searchParameter(char *name, DYNV_VectorGenericDataType *parametersVector);
static int readConfigurationFile(char *path, DYNV_VectorGenericDataType *parametersVector);
void destroyConfigurationVectorElement(void * data)
{
free( ((parameter_DataType *) data)->value);
free( ((parameter_DataType *) data)->name);
}
/* Public Functions */
int searchUser(char *name, DYNV_VectorGenericDataType *usersVector)
{
@ -66,18 +72,14 @@ void configurationRead(ftpParameters_DataType *ftpParameters)
if (FILE_IsFile(LOCAL_CONFIGURATION_FILENAME) == 1)
{
printf("\nReading configuration from \n -> %s \n", LOCAL_CONFIGURATION_FILENAME);
returnCode = readConfigurationFile(LOCAL_CONFIGURATION_FILENAME, &configParameters);
printf("\nDONE\n");
}
else if (FILE_IsFile(DEFAULT_CONFIGURATION_FILENAME) == 1)
{
printf("\nReading configuration from \n -> %s\n", DEFAULT_CONFIGURATION_FILENAME);
returnCode = readConfigurationFile(DEFAULT_CONFIGURATION_FILENAME, &configParameters);
printf("\nDONE\n");
}
@ -92,6 +94,9 @@ void configurationRead(ftpParameters_DataType *ftpParameters)
exit(1);
}
DYNV_VectorGeneric_Destroy(&configParameters, destroyConfigurationVectorElement);
return;
}

View File

@ -56,7 +56,7 @@ static void ignore_sigpipe(void)
}
}
void onUftpClose(void)
void onUftpClose(int sig)
{
printf("\nuFTP exit()\n");
deallocateMemory();

View File

@ -31,7 +31,7 @@ extern "C" {
void signalHandlerInstall(void);
void signal_callback_handler(int signum);
void onUftpClose(void);
void onUftpClose(int sig);
#ifdef __cplusplus
}

View File

@ -50,7 +50,7 @@ OBJECTFILES= \
# C Compiler Flags
CFLAGS=-pthread
CFLAGS=
# CC Compiler Flags
CCFLAGS=
@ -63,7 +63,7 @@ FFLAGS=
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
LDLIBSOPTIONS=-lpthread `pkg-config --libs libcrypto` `pkg-config --libs libssl` `pkg-config --libs openssl`
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
@ -71,67 +71,67 @@ LDLIBSOPTIONS=
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp: ${OBJECTFILES}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp ${OBJECTFILES} ${LDLIBSOPTIONS}
gcc -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/ftpCommandElaborate.o: ftpCommandElaborate.c
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpCommandElaborate.o ftpCommandElaborate.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpCommandElaborate.o ftpCommandElaborate.c
${OBJECTDIR}/ftpData.o: ftpData.c
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpData.o ftpData.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpData.o ftpData.c
${OBJECTDIR}/ftpServer.o: ftpServer.c
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpServer.o ftpServer.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpServer.o ftpServer.c
${OBJECTDIR}/library/configRead.o: library/configRead.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/configRead.o library/configRead.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/configRead.o library/configRead.c
${OBJECTDIR}/library/connection.o: library/connection.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/connection.o library/connection.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/connection.o library/connection.c
${OBJECTDIR}/library/daemon.o: library/daemon.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/daemon.o library/daemon.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/daemon.o library/daemon.c
${OBJECTDIR}/library/dynamicVectors.o: library/dynamicVectors.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/dynamicVectors.o library/dynamicVectors.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/dynamicVectors.o library/dynamicVectors.c
${OBJECTDIR}/library/fileManagement.o: library/fileManagement.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/fileManagement.o library/fileManagement.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/fileManagement.o library/fileManagement.c
${OBJECTDIR}/library/logFunctions.o: library/logFunctions.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/logFunctions.o library/logFunctions.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/logFunctions.o library/logFunctions.c
${OBJECTDIR}/library/openSsl.o: library/openSsl.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/openSsl.o library/openSsl.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/openSsl.o library/openSsl.c
${OBJECTDIR}/library/signals.o: library/signals.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/signals.o library/signals.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/signals.o library/signals.c
${OBJECTDIR}/uFTP.o: uFTP.c
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/uFTP.o uFTP.c
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/uFTP.o uFTP.c
# Subprojects
.build-subprojects:

View File

@ -50,7 +50,7 @@ OBJECTFILES= \
# C Compiler Flags
CFLAGS=
CFLAGS=-pthread -ssl -crypto
# CC Compiler Flags
CCFLAGS=

View File

@ -54,6 +54,7 @@
displayName="Important Files"
projectFiles="false"
kind="IMPORTANT_FILES_FOLDER">
<itemPath>MakeFileGeneric</itemPath>
<itemPath>Makefile</itemPath>
</logicalFolder>
</logicalFolder>
@ -64,7 +65,7 @@
<confs>
<conf name="Debug" type="1">
<toolsSet>
<compilerSet>default</compilerSet>
<compilerSet>GNU|GNU</compilerSet>
<dependencyChecking>true</dependencyChecking>
<rebuildPropChanged>false</rebuildPropChanged>
</toolsSet>
@ -78,11 +79,20 @@
<pElem>library/dynamicVectors.h</pElem>
<pElem>library/fileManagement.h</pElem>
</incFile>
<commandLine>-pthread</commandLine>
<preprocessorList>
<Elem>_LARGEFILE64_SOURCE</Elem>
</preprocessorList>
<warningLevel>2</warningLevel>
</cTool>
<linkerTool>
<commandlineTool>gcc</commandlineTool>
<linkerLibItems>
<linkerLibStdlibItem>PosixThreads</linkerLibStdlibItem>
<linkerOptionItem>`pkg-config --libs libcrypto`</linkerOptionItem>
<linkerOptionItem>`pkg-config --libs libssl`</linkerOptionItem>
<linkerOptionItem>`pkg-config --libs openssl`</linkerOptionItem>
</linkerLibItems>
</linkerTool>
</compileType>
<item path="MakeFileGeneric" ex="false" tool="3" flavor2="0">
</item>
@ -150,6 +160,7 @@
<compileType>
<cTool>
<developmentMode>5</developmentMode>
<commandLine>-pthread -ssl -crypto</commandLine>
</cTool>
<ccTool>
<developmentMode>5</developmentMode>

View File

@ -7,19 +7,7 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/home/ugo/NetBeansProjects/uFTP/library/signals.c</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/library/signals.h</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpServer.c</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/uFTP.c</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/MakeFileGeneric</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpServer.h</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/library/openSsl.c</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpData.h</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/library/configRead.c</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpCommandsElaborate.h</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpData.c</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/library/openSsl.h</file>
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpCommandElaborate.c</file>
</group>
</open-files>
</project-private>