ex_data.c (325335) | ex_data.c (325337) |
---|---|
1/* crypto/ex_data.c */ 2 3/* 4 * Overhaul notes; 5 * 6 * This code is now *mostly* thread-safe. It is now easier to understand in what 7 * ways it is safe and in what ways it is not, which is an improvement. Firstly, 8 * all per-class stacks and index-counters for ex_data are stored in the same --- 459 unchanged lines hidden (view full) --- 468 if ((item = def_get_class(class_index)) == NULL) 469 return 0; 470 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); 471 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); 472 j = sk_void_num(from->sk); 473 if (j < mx) 474 mx = j; 475 if (mx > 0) { | 1/* crypto/ex_data.c */ 2 3/* 4 * Overhaul notes; 5 * 6 * This code is now *mostly* thread-safe. It is now easier to understand in what 7 * ways it is safe and in what ways it is not, which is an improvement. Firstly, 8 * all per-class stacks and index-counters for ex_data are stored in the same --- 459 unchanged lines hidden (view full) --- 468 if ((item = def_get_class(class_index)) == NULL) 469 return 0; 470 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); 471 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); 472 j = sk_void_num(from->sk); 473 if (j < mx) 474 mx = j; 475 if (mx > 0) { |
476 if (!CRYPTO_set_ex_data(to, mx - 1, NULL)) | 476 /* 477 * Make sure the ex_data stack is at least |mx| elements long to avoid 478 * issues in the for loop that follows; so go get the |mx|'th element 479 * (if it does not exist CRYPTO_get_ex_data() returns NULL), and assign 480 * to itself. This is normally a no-op; but ensures the stack is the 481 * proper size 482 */ 483 if (!CRYPTO_set_ex_data(to, mx - 1, CRYPTO_get_ex_data(to, mx - 1))) |
477 goto skip; 478 storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS *)); 479 if (!storage) 480 goto skip; 481 for (i = 0; i < mx; i++) 482 storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i); 483 } 484 skip: --- 169 unchanged lines hidden --- | 484 goto skip; 485 storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS *)); 486 if (!storage) 487 goto skip; 488 for (i = 0; i < mx; i++) 489 storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i); 490 } 491 skip: --- 169 unchanged lines hidden --- |