fix snifftest pcap frees on file mode, close TraceFile on ssl_Free

This commit is contained in:
toddouska 2013-12-10 16:17:43 -08:00
parent 0d85a85d59
commit 9e56ad262c
2 changed files with 23 additions and 8 deletions

View File

@ -417,6 +417,13 @@ void ssl_FreeSniffer(void)
FreeMutex(&SessionMutex);
FreeMutex(&ServerListMutex);
if (TraceFile) {
TraceOn = 0;
fclose(TraceFile);
TraceFile = NULL;
}
CyaSSL_Cleanup();
}

View File

@ -69,18 +69,25 @@ enum {
};
pcap_t* pcap = 0;
pcap_if_t *alldevs;
pcap_t* pcap = NULL;
pcap_if_t* alldevs = NULL;
static void FreeAll(void)
{
if (pcap)
pcap_close(pcap);
if (alldevs)
pcap_freealldevs(alldevs);
#ifndef _WIN32
ssl_FreeSniffer();
#endif
}
static void sig_handler(const int sig)
{
printf("SIGINT handled = %d.\n", sig);
if (pcap)
pcap_close(pcap);
pcap_freealldevs(alldevs);
#ifndef _WIN32
ssl_FreeSniffer();
#endif
FreeAll();
if (sig)
exit(EXIT_SUCCESS);
}
@ -286,6 +293,7 @@ int main(int argc, char** argv)
else if (saveFile)
break; /* we're done reading file */
}
FreeAll();
return EXIT_SUCCESS;
}