Re: generating sha256 hashes with openssl?

  • From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 22 Aug 2010 21:30:37 -0600

#include <iostream>
#include <string>
#include <cstring>

int main(void)
{
char* i = new char(10);
memset(i, 0, 10);
strcpy(i, "hello!");
std::string s=i;
delete [] i;
std::cout << s << std::endl;
return 0;
}

tyler@tangerine:~$ g++ poc.cpp
tyler@tangerine:~$ ./a.out
hello!
tyler@tangerine:~$
so... It -is- copying, as I said earlier.
the std::string manages it's own array, so it can expand and etc. A smart pointer won't do any good as it's not used after the strcpy, thus deleting it has no affect here.
Thanks,
Ty

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: