2

When using the Botan::SecureVector in the following unit test:

void UnitTest()
{
    std::vector<byte> vbData;
    vbData.push_back(0x04);
    vbData.push_back(0x04);
    vbData.push_back(0x04);

    Botan::SecureVector<Botan::byte> svData(&vbData[0], vbData.size());
    CPPUNIT_ASSERT(vbData == std::vector<byte>(svData.begin(), svData.end()));
}

a segmentation fault occurs when trying to allocate the SecureVector as it tries to deallocate a buffer during its construction.

J. Polfer
  • 12,251
  • 10
  • 54
  • 83
  • 1
    You declare a vector called `vbData` and then use a vector called `bbData` (first letter is different). Is that potentially the error (is there a global `bbData`?) or is that just a typo? – Tyler McHenry May 25 '10 at 16:06
  • 1
    What you are encountering here is a bug; it was found and fixed in March (but a new stable release hasn't been spun, so it's still out there). It only occurred when the library wasn't initialized, but definitely a crash is never good behavior. The initialization is necessary because SecureVector wants to be able to access a shared pooling allocator that manages locked memory. BTW, may I suggest if you run into further problems with botan to try the botan-devel mailing list - people there are friendly, know the library, and often you can get answers quickly. – Jack Lloyd Jun 07 '10 at 22:26
  • @Jack Lloyd - Many thanks; I've signed onto the list. – J. Polfer Jun 11 '10 at 01:15

1 Answers1

3

Add line:

LibraryInitializer botanInit;

to function.

This seemed to me to be odd behavior, so I figured I should post it.

J. Polfer
  • 12,251
  • 10
  • 54
  • 83