diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2016-01-25 21:20:35 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2016-01-25 21:20:35 +0000 |
commit | 80148955f82c205cc94f0112e0fbfe8f91bc4330 (patch) | |
tree | 252a0ae41cdb2ad3d798e311fb728b04e5bdbdbd /plugins/CryptoPP/src/cpp_misc.cpp | |
parent | a289103f2834d2219799f8d84e29a6d69c00574a (diff) |
Crypto++: Fix for many memory leaks introduced in [6593].
Note that replaceStr already does mir_strdup the argument!
git-svn-id: http://svn.miranda-ng.org/main/trunk@16168 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP/src/cpp_misc.cpp')
-rw-r--r-- | plugins/CryptoPP/src/cpp_misc.cpp | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/plugins/CryptoPP/src/cpp_misc.cpp b/plugins/CryptoPP/src/cpp_misc.cpp index a0721ed5f3..6f9ca08ab4 100644 --- a/plugins/CryptoPP/src/cpp_misc.cpp +++ b/plugins/CryptoPP/src/cpp_misc.cpp @@ -2,13 +2,17 @@ int __cdecl cpp_get_features(HANDLE context)
{
- pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context);
+ if (!ptr)
+ return 0;
return ptr->features;
}
int __cdecl cpp_get_error(HANDLE context)
{
- pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context);
+ if (!ptr)
+ return 0;
return ptr->error;
}
@@ -19,7 +23,9 @@ int __cdecl cpp_get_version(void) BOOL cpp_get_simdata(HANDLE context, pCNTX *ptr, pSIMDATA *p)
{
- *ptr = get_context_on_id(context); if (!ptr) return 0;
+ if (!ptr)
+ return 0;
+ *ptr = get_context_on_id(context);
if (!*ptr || (*ptr)->mode&(MODE_PGP | MODE_GPG | MODE_RSA)) return FALSE;
*p = (pSIMDATA)cpp_alloc_pdata(*ptr);
return TRUE;
@@ -32,14 +38,20 @@ int __cdecl cpp_size_keyx(void) void __cdecl cpp_get_keyx(HANDLE context, BYTE *key)
{
- pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context, &ptr, &p)) return;
+ pCNTX ptr;
+ pSIMDATA p;
+ if (!cpp_get_simdata(context, &ptr, &p))
+ return;
memcpy(key, p->KeyX, Tiger::DIGESTSIZE);
memcpy(key + Tiger::DIGESTSIZE, &ptr->features, 2);
}
void __cdecl cpp_set_keyx(HANDLE context, BYTE *key)
{
- pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context, &ptr, &p)) return;
+ pCNTX ptr;
+ pSIMDATA p;
+ if (!cpp_get_simdata(context, &ptr, &p))
+ return;
SAFE_FREE(p->PubA);
SAFE_FREE(p->KeyA);
mir_free(p->KeyB); p->KeyB = 0;
@@ -51,7 +63,10 @@ void __cdecl cpp_set_keyx(HANDLE context, BYTE *key) void __cdecl cpp_get_keyp(HANDLE context, BYTE *key)
{
- pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context, &ptr, &p)) return;
+ pCNTX ptr;
+ pSIMDATA p;
+ if (!cpp_get_simdata(context, &ptr, &p))
+ return;
memcpy(key, p->KeyP, Tiger::DIGESTSIZE);
}
@@ -62,7 +77,10 @@ int __cdecl cpp_size_keyp(void) void __cdecl cpp_set_keyp(HANDLE context, BYTE *key)
{
- pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context, &ptr, &p)) return;
+ pCNTX ptr;
+ pSIMDATA p;
+ if (!cpp_get_simdata(context, &ptr, &p))
+ return;
SAFE_FREE(p->KeyP);
p->KeyP = (PBYTE)malloc(Tiger::DIGESTSIZE);
memcpy(p->KeyP, key, Tiger::DIGESTSIZE);
@@ -70,24 +88,36 @@ void __cdecl cpp_set_keyp(HANDLE context, BYTE *key) int __cdecl cpp_keya(HANDLE context)
{
- pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context, &ptr, &p)) return 0;
+ pCNTX ptr;
+ pSIMDATA p;
+ if (!cpp_get_simdata(context, &ptr, &p))
+ return 0;
return p->KeyA != NULL;
}
int __cdecl cpp_keyb(HANDLE context)
{
- pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context, &ptr, &p)) return 0;
+ pCNTX ptr;
+ pSIMDATA p;
+ if (!cpp_get_simdata(context, &ptr, &p))
+ return 0;
return p->KeyB != NULL;
}
int __cdecl cpp_keyx(HANDLE context)
{
- pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context, &ptr, &p)) return 0;
+ pCNTX ptr;
+ pSIMDATA p;
+ if (!cpp_get_simdata(context, &ptr, &p))
+ return 0;
return p->KeyX != NULL;
}
int __cdecl cpp_keyp(HANDLE context)
{
- pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context, &ptr, &p)) return 0;
+ pCNTX ptr;
+ pSIMDATA p;
+ if (!cpp_get_simdata(context, &ptr, &p))
+ return 0;
return p->KeyP != NULL;
}
|