0

我对 AXTLS 有一个小问题。我正在尝试与服务器建立 SSL 通信,但看起来它在“ssl_client_new”函数中双重释放了某些东西。

该代码创建一个新的 ctx (ssl_ctx_new) 并在初始化期间加载证书 (ssl_obj_load)(这里没问题),套接字已连接,当我调用“ssl_client_new”时,libc 检测到双重释放:

“双重免费或损坏(fasttop):0x0809f740”

我在 gdb 下启动了应用程序,这是回溯:

Program received signal SIGABRT, Aborted. 0xb7fdd424 in
__kernel_vsyscall () (gdb) bt
#0  0xb7fdd424 in __kernel_vsyscall ()
#1  0xb7d371ef in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0xb7d3a835 in __GI_abort () at abort.c:91
#3  0xb7d722fa in __libc_message (do_abort=2, fmt=0xb7e6a3bc "*** glibc detected *** %s: %s: 0x%s ***\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:201
#4  0xb7d7ce42 in malloc_printerr (action=<optimized out>, str=<optimized out>, ptr=0x809f740) at malloc.c:5007
#5  0x080712fd in asn1_name ()
#6  0x0806849f in x509_new ()
#7  0x080642cc in process_certificate ()
#8  0x08067caa in do_clnt_handshake ()
#9  0x08066675 in basic_read ()
#10 0x08067a07 in ssl_client_new ()

ctx指针和sockets没问题,最后两个参数为NULL和0。( http://axtls.sourceforge.net/dox/group_c_api.html#ga4eef242a559b06d72b862c1e5ab3d0a2 )

这是我的套接字的 strace:

socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 8

fcntl64(8, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
connect(8, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("81.12.132.173")}, 16) = -1 EINPROGRESS (Operation now in progress)
select(9, NULL, [8], NULL, {10, 0})     = 1 (out [8], left {9, 996818})
getsockopt(8, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
fcntl64(8, F_SETFL, O_RDWR)             = 0

fcntl64(8, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(8, F_SETFL, O_RDWR)             = 0

write(8, "\26\3\1\0003\1\0\0/\3\1P@hf?\222Y\3046n\215\364\317\34-D8\311\270=\225"..., 56) = 56
read(8, "\26\3\1\0J", 5)                = 5
read(8, "\2\0\0F\3\1Q\301_\210\267\200\352*}H\330\265\n;\33\253\31\24\320\377+\3\371\276g\362"..., 74) = 74

read(8, "\26\3\1\20)", 5)               = 5
read(8, "\v\0\20%\0\20\"\0\5\0070\202\5\0030\202\3\353\240\3\2\1\2\2\23w\0\0~\263\3446"..., 4137) = 2632
read(8, "1\0270\25\6\3U\4\n\f\16Vodafone Group1)0'\6\3U"..., 1505) = 1505

所以ssl握手开始了。在此之后立即:

open("/dev/tty", O_RDWR|O_NOCTTY|O_NONBLOCK) = 9
writev(9, [{"*** glibc detected *** ", 23}, {"./HTTPS_TOOL", 11}, {": ", 2}, {"double free or corruption (fastt"..., 35}, {": 0x", 4}, {"082ba740", 8}, {" ***\n", 5}], 7*** glibc detected *** ./HTTPS_TOOL: double free or corruption (fasttop): 0x082ba740 ***
) = 88

有任何想法吗?哪个可能是问题,我该怎么办?

谢谢你。

4

1 回答 1

0

你还在解决这个问题吗?我还没有任何关于此的报告,这可能是图书馆被使用的一种方式。

该库已在 Valgrind 中检查过多次,最近没有任何问题。您能否在 Valgrind 中运行它来验证?

于 2013-01-06T23:51:40.097 回答