Commit b963f807 authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

- Remo Inverardi noticed that ENGINEs don't have an "up_ref" function in the

normal 'structural' case (ENGINE_init() satisfies this in the less normal
'functional' case). This change provides such a function.

- Correct some "read" locks that should actually be "write" locks.

- make update.
parent 005bbb52
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
/* crypto/engine/eng_err.c */
/* ====================================================================
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 * Copyright (c) 1999-2002 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
@@ -96,6 +96,7 @@ static ERR_STRING_DATA ENGINE_str_functs[]=
{ERR_PACK(0,ENGINE_F_ENGINE_SET_NAME,0),	"ENGINE_set_name"},
{ERR_PACK(0,ENGINE_F_ENGINE_TABLE_REGISTER,0),	"ENGINE_TABLE_REGISTER"},
{ERR_PACK(0,ENGINE_F_ENGINE_UNLOAD_KEY,0),	"ENGINE_UNLOAD_KEY"},
{ERR_PACK(0,ENGINE_F_ENGINE_UP_REF,0),	"ENGINE_up_ref"},
{ERR_PACK(0,ENGINE_F_INT_CTRL_HELPER,0),	"INT_CTRL_HELPER"},
{ERR_PACK(0,ENGINE_F_INT_ENGINE_CONFIGURE,0),	"INT_ENGINE_CONFIGURE"},
{ERR_PACK(0,ENGINE_F_LOG_MESSAGE,0),	"LOG_MESSAGE"},
+22 −11
Original line number Diff line number Diff line
@@ -191,14 +191,14 @@ ENGINE *ENGINE_get_first(void)
	{
	ENGINE *ret;

	CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
	ret = engine_list_head;
	if(ret)
		{
		ret->struct_ref++;
		engine_ref_debug(ret, 0, 1)
		}
	CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
	return ret;
	}

@@ -206,14 +206,14 @@ ENGINE *ENGINE_get_last(void)
	{
	ENGINE *ret;

	CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
	ret = engine_list_tail;
	if(ret)
		{
		ret->struct_ref++;
		engine_ref_debug(ret, 0, 1)
		}
	CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
	return ret;
	}

@@ -227,7 +227,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
			ERR_R_PASSED_NULL_PARAMETER);
		return 0;
		}
	CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
	ret = e->next;
	if(ret)
		{
@@ -235,7 +235,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
		ret->struct_ref++;
		engine_ref_debug(ret, 0, 1)
		}
	CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
	/* Release the structural reference to the previous ENGINE */
	ENGINE_free(e);
	return ret;
@@ -250,7 +250,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
			ERR_R_PASSED_NULL_PARAMETER);
		return 0;
		}
	CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
	ret = e->prev;
	if(ret)
		{
@@ -258,7 +258,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
		ret->struct_ref++;
		engine_ref_debug(ret, 0, 1)
		}
	CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
	/* Release the structural reference to the previous ENGINE */
	ENGINE_free(e);
	return ret;
@@ -346,7 +346,7 @@ ENGINE *ENGINE_by_id(const char *id)
			ERR_R_PASSED_NULL_PARAMETER);
		return NULL;
		}
	CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
	iterator = engine_list_head;
	while(iterator && (strcmp(id, iterator->id) != 0))
		iterator = iterator->next;
@@ -372,7 +372,7 @@ ENGINE *ENGINE_by_id(const char *id)
			engine_ref_debug(iterator, 0, 1)
			}
		}
	CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
	CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
	if(iterator == NULL)
		{
		ENGINEerr(ENGINE_F_ENGINE_BY_ID,
@@ -381,3 +381,14 @@ ENGINE *ENGINE_by_id(const char *id)
		}
	return iterator;
	}

int ENGINE_up_ref(ENGINE *e)
	{
	if (e == NULL)
		{
		ENGINEerr(ENGINE_F_ENGINE_UP_REF,ERR_R_PASSED_NULL_PARAMETER);
		return 0;
		}
	CRYPTO_add(&e->struct_ref,1,CRYPTO_LOCK_ENGINE);
	return 1;
	}
+2 −0
Original line number Diff line number Diff line
@@ -406,6 +406,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
 * compatibility! */
ENGINE *ENGINE_new(void);
int ENGINE_free(ENGINE *e);
int ENGINE_up_ref(ENGINE *e);
int ENGINE_set_id(ENGINE *e, const char *id);
int ENGINE_set_name(ENGINE *e, const char *name);
int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
@@ -662,6 +663,7 @@ void ERR_load_ENGINE_strings(void);
#define ENGINE_F_ENGINE_SET_NAME			 130
#define ENGINE_F_ENGINE_TABLE_REGISTER			 184
#define ENGINE_F_ENGINE_UNLOAD_KEY			 152
#define ENGINE_F_ENGINE_UP_REF				 190
#define ENGINE_F_INT_CTRL_HELPER			 172
#define ENGINE_F_INT_ENGINE_CONFIGURE			 188
#define ENGINE_F_LOG_MESSAGE				 141
+1 −0
Original line number Diff line number Diff line
@@ -2793,3 +2793,4 @@ ASN1_UNIVERSALSTRING_it 3234 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
d2i_ASN1_UNIVERSALSTRING                3235	EXIST::FUNCTION:
EVP_des_ede3_ecb                        3236	EXIST::FUNCTION:DES
X509_REQ_print_ex                       3237	EXIST::FUNCTION:BIO
ENGINE_up_ref                           3238	EXIST::FUNCTION: