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: ...@@ -10,7 +10,7 @@ everything:
$(MAKE) $(T) --directory=client $(MAKE) $(T) --directory=client
$(MAKE) $(T) --directory=server $(MAKE) $(T) --directory=server
copybin: copybin: everything
rm -f ./stunserver ./stunclient ./stuntestcode rm -f ./stunserver ./stunclient ./stuntestcode
cp server/stunserver . cp server/stunserver .
cp client/stunclient . cp client/stunclient .
......
BOOST_INCLUDE := -I/home/jselbie/lib/boost_1_46_1 # BOOST_INCLUDE := -I/home/jselbie/lib/boost_1_46_1
# OPENSSL_INCLUDE := /home/jselbie/lib/openssl # OPENSSL_INCLUDE := -I/home/jselbie/lib/openssl
DEFINES := -DNDEBUG DEFINES := -DNDEBUG
......
...@@ -145,6 +145,7 @@ HRESULT CStunMessageReader::ValidateMessageIntegrity(uint8_t* key, size_t keylen ...@@ -145,6 +145,7 @@ HRESULT CStunMessageReader::ValidateMessageIntegrity(uint8_t* key, size_t keylen
CRefCountedBuffer spBuffer; CRefCountedBuffer spBuffer;
StunAttribute attribIntegrity; StunAttribute attribIntegrity;
int cmp = 0; int cmp = 0;
bool fContextInit = false;
ChkIf(_state != BodyValidated, E_FAIL); ChkIf(_state != BodyValidated, E_FAIL);
ChkIf(_indexMessageIntegrity < 0, E_FAIL); ChkIf(_indexMessageIntegrity < 0, E_FAIL);
...@@ -171,6 +172,7 @@ HRESULT CStunMessageReader::ValidateMessageIntegrity(uint8_t* key, size_t keylen ...@@ -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 // 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); HMAC_CTX_init(&ctx);
fContextInit = true;
HMAC_Init(&ctx, key, keylength, EVP_sha1()); HMAC_Init(&ctx, key, keylength, EVP_sha1());
// message type // message type
...@@ -213,6 +215,11 @@ HRESULT CStunMessageReader::ValidateMessageIntegrity(uint8_t* key, size_t keylen ...@@ -213,6 +215,11 @@ HRESULT CStunMessageReader::ValidateMessageIntegrity(uint8_t* key, size_t keylen
hr = (cmp == 0 ? S_OK : E_FAIL); hr = (cmp == 0 ? S_OK : E_FAIL);
Cleanup: Cleanup:
if (fContextInit)
{
HMAC_CTX_cleanup(&ctx);
}
return hr; return hr;
} }
......
...@@ -352,6 +352,9 @@ HRESULT CTestClientLogic::TestBehaviorAndFiltering(bool fBehaviorTest, NatBehavi ...@@ -352,6 +352,9 @@ HRESULT CTestClientLogic::TestBehaviorAndFiltering(bool fBehaviorTest, NatBehavi
ChkIfA(results.behavior != behavior, E_UNEXPECTED); ChkIfA(results.behavior != behavior, E_UNEXPECTED);
Cleanup: Cleanup:
_spTransport.ReleaseAndClear();
return hr; return hr;
} }
......
...@@ -67,15 +67,24 @@ void ReaderFuzzTest() ...@@ -67,15 +67,24 @@ void ReaderFuzzTest()
void RunUnitTests() void RunUnitTests()
{ {
std::vector<IUnitTest*> vecTests; std::vector<IUnitTest*> vecTests;
vecTests.push_back(new CTestDataStream()); boost::shared_ptr<CTestDataStream> spTestDataStream(new CTestDataStream);
vecTests.push_back(new CTestReader()); boost::shared_ptr<CTestReader> spTestReader(new CTestReader);
vecTests.push_back(new CTestBuilder()); boost::shared_ptr<CTestBuilder> spTestBuilder(new CTestBuilder);
vecTests.push_back(new CTestIntegrity()); boost::shared_ptr<CTestIntegrity> spTestIntegrity(new CTestIntegrity);
vecTests.push_back(new CTestMessageHandler()); boost::shared_ptr<CTestMessageHandler> spTestMessageHandler(new CTestMessageHandler);
vecTests.push_back(new CTestCmdLineParser()); boost::shared_ptr<CTestCmdLineParser> spTestCmdLineParser(new CTestCmdLineParser);
vecTests.push_back(new CTestClientLogic()); boost::shared_ptr<CTestClientLogic> spTestClientLogic(new CTestClientLogic);
vecTests.push_back(new CTestRecvFromEx()); 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++) 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