关于OPENSSL的一个问题

p-o-w-e-r 2013-09-02 05:20:07
在测试的时候,怎么测试都没有问题,结果上了生产后,就报了:
*** glibc detected *** ./SSRPQT: free(): invalid next size (fast): 0x0a119d70 ***
======= Backtrace: =========
/lib/libc.so.6[0x2bb595]
/lib/libc.so.6(cfree+0x59)[0x2bb9d9]
/lib/libcrypto.so.6(CRYPTO_free+0x3a)[0x448da5a]
/lib/libcrypto.so.6(BUF_MEM_free+0x47)[0x4412f07]
/lib/libcrypto.so.6[0x4414783]
/lib/libcrypto.so.6(BIO_free+0xc1)[0x4413f01]
/lib/libcrypto.so.6(BIO_free_all+0x34)[0x4413f54]
错误!SSRPQT是我的应用程序,我是把ssl的加解密放入了libcrypto.so中,然后供SSRPQT调用的。

有谁懂OpenSSL的,帮忙看下啊,
代码如下:

std::string Decrypt( const std::string& sInbuf, const std::string& sKey)
{
const char* inbuf = sInbuf.c_str();
unsigned char * key = (unsigned char *)sKey.c_str();
int inlen = sInbuf.length();
BIO *bio, *mbio, *cbio;
char *dst;
int outlen;

mbio = BIO_new( BIO_s_mem( ) );
cbio = BIO_new( BIO_f_cipher( ) );
BIO_set_cipher( cbio , EVP_des_ecb( ) , key , NULL , 0 );

bio = BIO_push( cbio , mbio );
BIO_write( bio , inbuf , inlen );
BIO_flush( bio );

outlen = BIO_get_mem_data( mbio , (char **) & dst );
dst[outlen] = '\0';
string sResult = dst;
BIO_free_all( bio );

return sResult;
}
...全文
106 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
BIO_free_all( bio )这里面会对bio多次free吗?

23,116

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧