Page MenuHomePhabricator

ssh_finalize() issue in 0.8.5
Open, Needs TriagePublic

Description

Calling:

ssh_init()
ssh_finalize()
ssh_init()

with libssh linked as static lib leads to access violation.

See https://curl.haxx.se/libcurl/c/opensslthreadlock.html. Seems calling

CRYPTO_set_id_callback(NULL);
CRYPTO_set_locking_callback(NULL);

is missing in crypto_thread_finalize() of file libcrypto.c

So on second ssh_init() call probably still the old libcrypto_lock_callback pointer is stored and called by openssl before CRYPTO_set_locking_callback() is newly set.

Event Timeline

chcg created this task.Thu, Nov 1, 12:55 AM
chcg added a comment.EditedThu, Nov 1, 12:59 AM

Used openssl version 1.0.2p.

Callstack:

 	NppFTP.dll!ssh_threads_set_callbacks()	C
>	NppFTP.dll!CRYPTO_lock(int mode, int type, const char * file, int line) Zeile 604	C
 	NppFTP.dll!CRYPTO_mem_ctrl(int mode) Zeile 213	C
 	NppFTP.dll!OBJ_NAME_init() Zeile 61	C
 	NppFTP.dll!OBJ_NAME_add(const char * name, int type, const char * data) Zeile 185	C
 	NppFTP.dll!EVP_add_cipher(const evp_cipher_st * c) Zeile 76	C
 	NppFTP.dll!OpenSSL_add_all_ciphers() Zeile 70	C
 	NppFTP.dll!OPENSSL_add_all_algorithms_noconf() Zeile 85	C
 	[Externer Code]	
 	NppFTP.dll!FTPClientWrapperSSH::connect_ssh() Zeile 405	C++
 	NppFTP.dll!FTPClientWrapperSSH::Connect() Zeile 66	C++
 	NppFTP.dll!QueueConnect::Perform() Zeile 185	C++
 	NppFTP.dll!FTPQueue::QueueLoop() Zeile 200	C++
 	NppFTP.dll!FTPQueue::QueueThread(FTPQueue * queue) Zeile 264	C++
 	NppFTP.dll!ThreadProc(void * param) Zeile 269	C++
 	[Externer Code]

with

+		file	0x00007ff94a927898 ".\\crypto\\mem_dbg.c"	const char *
		line	0x000000d4	int
		locking_callback	0x00007ff94a4b79af {NppFTP.dll!libcrypto_lock_callback}	void(*)(int, int, const char *, int)
		mode	0x00000009	int
		type	0x00000014	int

at CRYPTO_lock line 604 from cryptlib.c

chcg updated the task description. (Show Details)Thu, Nov 1, 1:04 AM