In message <[EMAIL PROTECTED]> on Fri, 06 Dec 2002 16:51:37 +0000, Bertie <[EMAIL PROTECTED]> said:
bertie> There is a bug in CRYPTO_get_new_dynlockid(), since the first bertie> time it gets called it returns -2 (not -1 as I expected) and bertie> when you call CRYPTO_lock (mode, -2, , ) it silently returns bertie> without actually locking anything because bertie> CRYPTO_get_dynlock_value(-2) returns NULL. Ah, looks like I misunderstood the value returned by sk_*_push() back when I wrote those routines. Also, it seems like I didn't have the pointer filled into the slot in the stack when I found an empty slot. I'm adding a patch. Care to try it? -- Richard Levitte \ Spannvägen 38, II \ [EMAIL PROTECTED] Redakteur@Stacken \ S-168 35 BROMMA \ T: +46-8-26 52 47 \ SWEDEN \ or +46-708-26 53 44 Procurator Odiosus Ex Infernis -- [EMAIL PROTECTED] Member of the OpenSSL development team: http://www.openssl.org/ Unsolicited commercial email is subject to an archival fee of $400. See <http://www.stacken.kth.se/~levitte/mail/> for more info.
Index: crypto/cryptlib.c =================================================================== RCS file: /e/openssl/cvs/openssl/crypto/cryptlib.c,v retrieving revision 1.32.2.5 diff -u -u -r1.32.2.5 cryptlib.c --- crypto/cryptlib.c 2002/11/12 13:20:47 1.32.2.5 +++ crypto/cryptlib.c 2002/12/07 00:26:51 @@ -207,10 +207,18 @@ i=sk_CRYPTO_dynlock_find(dyn_locks,NULL); /* If there was none, push, thereby creating a new one */ if (i == -1) - i=sk_CRYPTO_dynlock_push(dyn_locks,pointer); + /* Since sk_push() returns the number of items on the + stack, not the location of the pushed item, we need + to transform the returned number into a position, + by decreasing it. */ + i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1; + else + /* If we found a place with a NULL pointer, put our pointer + in it. */ + sk_CRYPTO_dynlock_set(dyn_locks,i,pointer); CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); - if (!i) + if (i == -1) { dynlock_destroy_callback(pointer->data,__FILE__,__LINE__); OPENSSL_free(pointer);