Commit 1fb49dbe authored by John Selbie's avatar John Selbie

Memory leaks, Makefile, and gitignore file.

parent 03f02ccb
nbproject/
*.o
*.gch
*.a
*.txtcode
stunclient
stunserver
stuntestcode
......@@ -10,7 +10,7 @@ everything:
$(MAKE) $(T) --directory=client
$(MAKE) $(T) --directory=server
copybin:
copybin: everything
rm -f ./stunserver ./stunclient ./stuntestcode
cp server/stunserver .
cp client/stunclient .
......
BOOST_INCLUDE := -I/home/jselbie/lib/boost_1_46_1
# OPENSSL_INCLUDE := /home/jselbie/lib/openssl
# BOOST_INCLUDE := -I/home/jselbie/lib/boost_1_46_1
# OPENSSL_INCLUDE := -I/home/jselbie/lib/openssl
DEFINES := -DNDEBUG
......
......@@ -145,6 +145,7 @@ HRESULT CStunMessageReader::ValidateMessageIntegrity(uint8_t* key, size_t keylen
CRefCountedBuffer spBuffer;
StunAttribute attribIntegrity;
int cmp = 0;
bool fContextInit = false;
ChkIf(_state != BodyValidated, E_FAIL);
ChkIf(_indexMessageIntegrity < 0, E_FAIL);
......@@ -171,6 +172,7 @@ HRESULT CStunMessageReader::ValidateMessageIntegrity(uint8_t* key, size_t keylen
// Here comes the fun part. If there is a fingerprint attribute, we have to adjust the length header in computing the hash
HMAC_CTX_init(&ctx);
fContextInit = true;
HMAC_Init(&ctx, key, keylength, EVP_sha1());
// message type
......@@ -213,6 +215,11 @@ HRESULT CStunMessageReader::ValidateMessageIntegrity(uint8_t* key, size_t keylen
hr = (cmp == 0 ? S_OK : E_FAIL);
Cleanup:
if (fContextInit)
{
HMAC_CTX_cleanup(&ctx);
}
return hr;
}
......
......@@ -352,6 +352,9 @@ HRESULT CTestClientLogic::TestBehaviorAndFiltering(bool fBehaviorTest, NatBehavi
ChkIfA(results.behavior != behavior, E_UNEXPECTED);
Cleanup:
_spTransport.ReleaseAndClear();
return hr;
}
......
......@@ -67,15 +67,24 @@ void ReaderFuzzTest()
void RunUnitTests()
{
std::vector<IUnitTest*> vecTests;
vecTests.push_back(new CTestDataStream());
vecTests.push_back(new CTestReader());
vecTests.push_back(new CTestBuilder());
vecTests.push_back(new CTestIntegrity());
vecTests.push_back(new CTestMessageHandler());
vecTests.push_back(new CTestCmdLineParser());
vecTests.push_back(new CTestClientLogic());
vecTests.push_back(new CTestRecvFromEx());
boost::shared_ptr<CTestDataStream> spTestDataStream(new CTestDataStream);
boost::shared_ptr<CTestReader> spTestReader(new CTestReader);
boost::shared_ptr<CTestBuilder> spTestBuilder(new CTestBuilder);
boost::shared_ptr<CTestIntegrity> spTestIntegrity(new CTestIntegrity);
boost::shared_ptr<CTestMessageHandler> spTestMessageHandler(new CTestMessageHandler);
boost::shared_ptr<CTestCmdLineParser> spTestCmdLineParser(new CTestCmdLineParser);
boost::shared_ptr<CTestClientLogic> spTestClientLogic(new CTestClientLogic);
boost::shared_ptr<CTestRecvFromEx> spTestRecvFromEx(new CTestRecvFromEx);
vecTests.push_back(spTestDataStream.get());
vecTests.push_back(spTestReader.get());
vecTests.push_back(spTestBuilder.get());
vecTests.push_back(spTestIntegrity.get());
vecTests.push_back(spTestMessageHandler.get());
vecTests.push_back(spTestCmdLineParser.get());
vecTests.push_back(spTestClientLogic.get());
vecTests.push_back(spTestRecvFromEx.get());
for (size_t index = 0; index < vecTests.size(); index++)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment