DynamoRIO / DynamoRIO/drmemory
Uninits in crypto-related code
- Dominant language
- C
- Stars
- 2.7k
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
_From [timurrrr@google.com](https://code.google.com/u/timurrrr@google.com/) on May 24, 2011 06:18:59_
Repro:
#
#include
#include
#include
#pragma comment(lib, "crypt32.lib")
#pragma comment(lib, "advapi32.lib")
#define ABORT(msg) do { fprintf(stderr, "Error: %s\n", msg); return 1; } while (0)
int main() {
HCRYPTPROV provider;
if (!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_AES, 0))
ABORT("CryptAcquireContext failed");
HCRYPTKEY key;
if (!CryptGenKey(provider, CALG_AES_256, CRYPT_EXPORTABLE, &key))
ABORT("CryptGenKey failed");
DWORD buffer_size = 0;
if (!CryptExportKey(key, 0, PLAINTEXTKEYBLOB, 0, NULL, &buffer_size))
ABORT("CryptExportKey-1 failed");
BYTE *buffer = new BYTE[buffer_size];
if (!buffer)
ABORT("Memory allocation failed");
if (!CryptExportKey(key, 0, PLAINTEXTKEYBLOB, 0, buffer, &buffer_size))
ABORT("CryptExportKey-2 failed");
// 12 = sizeof(BLOBheader) + 4 bytes for the length field
std::string str;
str.assign((char*)buffer+12, buffer_size-12);
printf("BLOB: `%s`\n", str.c_str());
delete [] buffer;
CryptDestroyKey(key);
CryptReleaseContext(provider, 0);
printf("PASS\n");
return 0;
}
#
WARNING: unhandled system call #0x1019
WARNING: unhandled system call #0x101e
WARNING: unhandled system call #0x102c
WARNING: unhandled system call #0x10c8
WARNING: unhandled system call #0x10dc
WARNING: unhandled system call #0x10f4
WARNING: unhandled system call #0x1101
WARNING: unhandled system call #0x1142
WARNING: unhandled system call #0x1143
WARNING: unhandled system call #0x1179
WARNING: unhandled system call #0x11b2
WARNING: unhandled system call #0x11e8
result in UNINIT reports on the printf line.
_Original issue: http://code.google.com/p/drmemory/issues/detail?id=412_
Contributor guide
Assessment
This issue has not been assessed yet.