diff options
author | beck <> | 2017-01-29 17:49:23 +0000 |
---|---|---|
committer | beck <> | 2017-01-29 17:49:23 +0000 |
commit | 957b11334a7afb14537322f0e4795b2e368b3f59 (patch) | |
tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/engine/eng_list.c | |
parent | df96e020e729c6c37a8c7fe311fdd1fe6a8718c5 (diff) | |
download | openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.gz openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.bz2 openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.zip |
Send the function codes from the error functions to the bit bucket,
as was done earlier in libssl. Thanks inoguchi@ for noticing
libssl had more reacharounds into this.
ok jsing@ inoguchi@
Diffstat (limited to 'src/lib/libcrypto/engine/eng_list.c')
-rw-r--r-- | src/lib/libcrypto/engine/eng_list.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c index fc1d16b183..8bb1bc58f2 100644 --- a/src/lib/libcrypto/engine/eng_list.c +++ b/src/lib/libcrypto/engine/eng_list.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_list.c,v 1.21 2015/07/19 00:56:48 bcook Exp $ */ | 1 | /* $OpenBSD: eng_list.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -105,8 +105,7 @@ engine_list_add(ENGINE *e) | |||
105 | ENGINE *iterator = NULL; | 105 | ENGINE *iterator = NULL; |
106 | 106 | ||
107 | if (e == NULL) { | 107 | if (e == NULL) { |
108 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 108 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); |
109 | ERR_R_PASSED_NULL_PARAMETER); | ||
110 | return 0; | 109 | return 0; |
111 | } | 110 | } |
112 | iterator = engine_list_head; | 111 | iterator = engine_list_head; |
@@ -115,15 +114,13 @@ engine_list_add(ENGINE *e) | |||
115 | iterator = iterator->next; | 114 | iterator = iterator->next; |
116 | } | 115 | } |
117 | if (conflict) { | 116 | if (conflict) { |
118 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 117 | ENGINEerror(ENGINE_R_CONFLICTING_ENGINE_ID); |
119 | ENGINE_R_CONFLICTING_ENGINE_ID); | ||
120 | return 0; | 118 | return 0; |
121 | } | 119 | } |
122 | if (engine_list_head == NULL) { | 120 | if (engine_list_head == NULL) { |
123 | /* We are adding to an empty list. */ | 121 | /* We are adding to an empty list. */ |
124 | if (engine_list_tail) { | 122 | if (engine_list_tail) { |
125 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 123 | ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); |
126 | ENGINE_R_INTERNAL_LIST_ERROR); | ||
127 | return 0; | 124 | return 0; |
128 | } | 125 | } |
129 | engine_list_head = e; | 126 | engine_list_head = e; |
@@ -135,8 +132,7 @@ engine_list_add(ENGINE *e) | |||
135 | /* We are adding to the tail of an existing list. */ | 132 | /* We are adding to the tail of an existing list. */ |
136 | if ((engine_list_tail == NULL) || | 133 | if ((engine_list_tail == NULL) || |
137 | (engine_list_tail->next != NULL)) { | 134 | (engine_list_tail->next != NULL)) { |
138 | ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, | 135 | ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); |
139 | ENGINE_R_INTERNAL_LIST_ERROR); | ||
140 | return 0; | 136 | return 0; |
141 | } | 137 | } |
142 | engine_list_tail->next = e; | 138 | engine_list_tail->next = e; |
@@ -158,8 +154,7 @@ engine_list_remove(ENGINE *e) | |||
158 | ENGINE *iterator; | 154 | ENGINE *iterator; |
159 | 155 | ||
160 | if (e == NULL) { | 156 | if (e == NULL) { |
161 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, | 157 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); |
162 | ERR_R_PASSED_NULL_PARAMETER); | ||
163 | return 0; | 158 | return 0; |
164 | } | 159 | } |
165 | /* We need to check that e is in our linked list! */ | 160 | /* We need to check that e is in our linked list! */ |
@@ -167,8 +162,7 @@ engine_list_remove(ENGINE *e) | |||
167 | while (iterator && (iterator != e)) | 162 | while (iterator && (iterator != e)) |
168 | iterator = iterator->next; | 163 | iterator = iterator->next; |
169 | if (iterator == NULL) { | 164 | if (iterator == NULL) { |
170 | ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, | 165 | ENGINEerror(ENGINE_R_ENGINE_IS_NOT_IN_LIST); |
171 | ENGINE_R_ENGINE_IS_NOT_IN_LIST); | ||
172 | return 0; | 166 | return 0; |
173 | } | 167 | } |
174 | /* un-link e from the chain. */ | 168 | /* un-link e from the chain. */ |
@@ -223,8 +217,7 @@ ENGINE_get_next(ENGINE *e) | |||
223 | ENGINE *ret = NULL; | 217 | ENGINE *ret = NULL; |
224 | 218 | ||
225 | if (e == NULL) { | 219 | if (e == NULL) { |
226 | ENGINEerr(ENGINE_F_ENGINE_GET_NEXT, | 220 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); |
227 | ERR_R_PASSED_NULL_PARAMETER); | ||
228 | return 0; | 221 | return 0; |
229 | } | 222 | } |
230 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 223 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
@@ -246,8 +239,7 @@ ENGINE_get_prev(ENGINE *e) | |||
246 | ENGINE *ret = NULL; | 239 | ENGINE *ret = NULL; |
247 | 240 | ||
248 | if (e == NULL) { | 241 | if (e == NULL) { |
249 | ENGINEerr(ENGINE_F_ENGINE_GET_PREV, | 242 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); |
250 | ERR_R_PASSED_NULL_PARAMETER); | ||
251 | return 0; | 243 | return 0; |
252 | } | 244 | } |
253 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 245 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
@@ -270,18 +262,15 @@ ENGINE_add(ENGINE *e) | |||
270 | int to_return = 1; | 262 | int to_return = 1; |
271 | 263 | ||
272 | if (e == NULL) { | 264 | if (e == NULL) { |
273 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 265 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); |
274 | ERR_R_PASSED_NULL_PARAMETER); | ||
275 | return 0; | 266 | return 0; |
276 | } | 267 | } |
277 | if ((e->id == NULL) || (e->name == NULL)) { | 268 | if ((e->id == NULL) || (e->name == NULL)) { |
278 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 269 | ENGINEerror(ENGINE_R_ID_OR_NAME_MISSING); |
279 | ENGINE_R_ID_OR_NAME_MISSING); | ||
280 | } | 270 | } |
281 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 271 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
282 | if (!engine_list_add(e)) { | 272 | if (!engine_list_add(e)) { |
283 | ENGINEerr(ENGINE_F_ENGINE_ADD, | 273 | ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); |
284 | ENGINE_R_INTERNAL_LIST_ERROR); | ||
285 | to_return = 0; | 274 | to_return = 0; |
286 | } | 275 | } |
287 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 276 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
@@ -295,14 +284,12 @@ ENGINE_remove(ENGINE *e) | |||
295 | int to_return = 1; | 284 | int to_return = 1; |
296 | 285 | ||
297 | if (e == NULL) { | 286 | if (e == NULL) { |
298 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, | 287 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); |
299 | ERR_R_PASSED_NULL_PARAMETER); | ||
300 | return 0; | 288 | return 0; |
301 | } | 289 | } |
302 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 290 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
303 | if (!engine_list_remove(e)) { | 291 | if (!engine_list_remove(e)) { |
304 | ENGINEerr(ENGINE_F_ENGINE_REMOVE, | 292 | ENGINEerror(ENGINE_R_INTERNAL_LIST_ERROR); |
305 | ENGINE_R_INTERNAL_LIST_ERROR); | ||
306 | to_return = 0; | 293 | to_return = 0; |
307 | } | 294 | } |
308 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 295 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
@@ -350,8 +337,7 @@ ENGINE_by_id(const char *id) | |||
350 | ENGINE *iterator; | 337 | ENGINE *iterator; |
351 | 338 | ||
352 | if (id == NULL) { | 339 | if (id == NULL) { |
353 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, | 340 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); |
354 | ERR_R_PASSED_NULL_PARAMETER); | ||
355 | return NULL; | 341 | return NULL; |
356 | } | 342 | } |
357 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 343 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
@@ -378,7 +364,7 @@ ENGINE_by_id(const char *id) | |||
378 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 364 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
379 | 365 | ||
380 | if (iterator == NULL) { | 366 | if (iterator == NULL) { |
381 | ENGINEerr(ENGINE_F_ENGINE_BY_ID, ENGINE_R_NO_SUCH_ENGINE); | 367 | ENGINEerror(ENGINE_R_NO_SUCH_ENGINE); |
382 | ERR_asprintf_error_data("id=%s", id); | 368 | ERR_asprintf_error_data("id=%s", id); |
383 | } | 369 | } |
384 | return iterator; | 370 | return iterator; |
@@ -388,7 +374,7 @@ int | |||
388 | ENGINE_up_ref(ENGINE *e) | 374 | ENGINE_up_ref(ENGINE *e) |
389 | { | 375 | { |
390 | if (e == NULL) { | 376 | if (e == NULL) { |
391 | ENGINEerr(ENGINE_F_ENGINE_UP_REF, ERR_R_PASSED_NULL_PARAMETER); | 377 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); |
392 | return 0; | 378 | return 0; |
393 | } | 379 | } |
394 | CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); | 380 | CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); |