diff options
Diffstat (limited to 'src/lib/libcrypto/store/str_mem.c')
| -rw-r--r-- | src/lib/libcrypto/store/str_mem.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/lib/libcrypto/store/str_mem.c b/src/lib/libcrypto/store/str_mem.c index 527757ae09..8ac4f7e55c 100644 --- a/src/lib/libcrypto/store/str_mem.c +++ b/src/lib/libcrypto/store/str_mem.c | |||
| @@ -76,30 +76,35 @@ | |||
| 76 | attribute type code). | 76 | attribute type code). |
| 77 | */ | 77 | */ |
| 78 | 78 | ||
| 79 | struct mem_object_data_st | 79 | typedef struct mem_object_data_st |
| 80 | { | 80 | { |
| 81 | STORE_OBJECT *object; | 81 | STORE_OBJECT *object; |
| 82 | STORE_ATTR_INFO *attr_info; | 82 | STORE_ATTR_INFO *attr_info; |
| 83 | int references; | 83 | int references; |
| 84 | }; | 84 | } MEM_OBJECT_DATA; |
| 85 | 85 | ||
| 86 | DECLARE_STACK_OF(MEM_OBJECT_DATA) | ||
| 86 | struct mem_data_st | 87 | struct mem_data_st |
| 87 | { | 88 | { |
| 88 | STACK *data; /* A stack of mem_object_data_st, | 89 | STACK_OF(MEM_OBJECT_DATA) *data; /* sorted with |
| 89 | sorted with STORE_ATTR_INFO_compare(). */ | 90 | * STORE_ATTR_INFO_compare(). */ |
| 90 | unsigned int compute_components : 1; /* Currently unused, but can | 91 | unsigned int compute_components : 1; /* Currently unused, but can |
| 91 | be used to add attributes | 92 | be used to add attributes |
| 92 | from parts of the data. */ | 93 | from parts of the data. */ |
| 93 | }; | 94 | }; |
| 94 | 95 | ||
| 96 | DECLARE_STACK_OF(STORE_ATTR_INFO) | ||
| 95 | struct mem_ctx_st | 97 | struct mem_ctx_st |
| 96 | { | 98 | { |
| 97 | int type; /* The type we're searching for */ | 99 | int type; /* The type we're searching for */ |
| 98 | STACK *search_attributes; /* Sets of attributes to search for. | 100 | STACK_OF(STORE_ATTR_INFO) *search_attributes; /* Sets of |
| 99 | Each element is a STORE_ATTR_INFO. */ | 101 | attributes to search for. Each |
| 100 | int search_index; /* which of the search attributes we found a match | 102 | element is a STORE_ATTR_INFO. */ |
| 101 | for, -1 when we still haven't found any */ | 103 | int search_index; /* which of the search attributes we |
| 102 | int index; /* -1 as long as we're searching for the first */ | 104 | found a match for, -1 when we still |
| 105 | haven't found any */ | ||
| 106 | int index; /* -1 as long as we're searching for | ||
| 107 | the first */ | ||
| 103 | }; | 108 | }; |
| 104 | 109 | ||
| 105 | static int mem_init(STORE *s); | 110 | static int mem_init(STORE *s); |
| @@ -240,7 +245,7 @@ static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, | |||
| 240 | if (context->search_attributes == NULL) | 245 | if (context->search_attributes == NULL) |
| 241 | { | 246 | { |
| 242 | context->search_attributes = | 247 | context->search_attributes = |
| 243 | sk_new((int (*)(const char * const *, const char * const *))STORE_ATTR_INFO_compare); | 248 | sk_STORE_ATTR_INFO_new(STORE_ATTR_INFO_compare); |
| 244 | if (!context->search_attributes) | 249 | if (!context->search_attributes) |
| 245 | { | 250 | { |
| 246 | STOREerr(STORE_F_MEM_LIST_START, | 251 | STOREerr(STORE_F_MEM_LIST_START, |
| @@ -248,7 +253,7 @@ static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type, | |||
| 248 | goto err; | 253 | goto err; |
| 249 | } | 254 | } |
| 250 | } | 255 | } |
| 251 | sk_push(context->search_attributes,(char *)attrs); | 256 | sk_STORE_ATTR_INFO_push(context->search_attributes,attrs); |
| 252 | } | 257 | } |
| 253 | if (!STORE_parse_attrs_endp(attribute_context)) | 258 | if (!STORE_parse_attrs_endp(attribute_context)) |
| 254 | goto err; | 259 | goto err; |
| @@ -284,11 +289,14 @@ static STORE_OBJECT *mem_list_next(STORE *s, void *handle) | |||
| 284 | 289 | ||
| 285 | if (context->search_index == -1) | 290 | if (context->search_index == -1) |
| 286 | { | 291 | { |
| 287 | for (i = 0; i < sk_num(context->search_attributes); i++) | 292 | for (i = 0; |
| 293 | i < sk_STORE_ATTR_INFO_num(context->search_attributes); | ||
| 294 | i++) | ||
| 288 | { | 295 | { |
| 289 | key.attr_info = | 296 | key.attr_info |
| 290 | (STORE_ATTR_INFO *)sk_value(context->search_attributes, i); | 297 | = sk_STORE_ATTR_INFO_value(context->search_attributes, |
| 291 | srch = sk_find_ex(store->data, (char *)&key); | 298 | i); |
| 299 | srch = sk_MEM_OBJECT_DATA_find_ex(store->data, &key); | ||
| 292 | 300 | ||
| 293 | if (srch >= 0) | 301 | if (srch >= 0) |
| 294 | { | 302 | { |
| @@ -301,21 +309,20 @@ static STORE_OBJECT *mem_list_next(STORE *s, void *handle) | |||
| 301 | return NULL; | 309 | return NULL; |
| 302 | 310 | ||
| 303 | key.attr_info = | 311 | key.attr_info = |
| 304 | (STORE_ATTR_INFO *)sk_value(context->search_attributes, | 312 | sk_STORE_ATTR_INFO_value(context->search_attributes, |
| 305 | context->search_index); | 313 | context->search_index); |
| 306 | for(srch = context->search_index; | 314 | for(srch = context->search_index; |
| 307 | srch < sk_num(store->data) | 315 | srch < sk_MEM_OBJECT_DATA_num(store->data) |
| 308 | && STORE_ATTR_INFO_in_range(key.attr_info, | 316 | && STORE_ATTR_INFO_in_range(key.attr_info, |
| 309 | (STORE_ATTR_INFO *)sk_value(store->data, srch)) | 317 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info) |
| 310 | && !(cres = STORE_ATTR_INFO_in_ex(key.attr_info, | 318 | && !(cres = STORE_ATTR_INFO_in_ex(key.attr_info, |
| 311 | (STORE_ATTR_INFO *)sk_value(store->data, srch))); | 319 | sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info)); |
| 312 | srch++) | 320 | srch++) |
| 313 | ; | 321 | ; |
| 314 | 322 | ||
| 315 | context->search_index = srch; | 323 | context->search_index = srch; |
| 316 | if (cres) | 324 | if (cres) |
| 317 | return ((struct mem_object_data_st *)sk_value(store->data, | 325 | return (sk_MEM_OBJECT_DATA_value(store->data, srch))->object; |
| 318 | srch))->object; | ||
| 319 | return NULL; | 326 | return NULL; |
| 320 | } | 327 | } |
| 321 | static int mem_list_end(STORE *s, void *handle) | 328 | static int mem_list_end(STORE *s, void *handle) |
| @@ -328,7 +335,7 @@ static int mem_list_end(STORE *s, void *handle) | |||
| 328 | return 0; | 335 | return 0; |
| 329 | } | 336 | } |
| 330 | if (context && context->search_attributes) | 337 | if (context && context->search_attributes) |
| 331 | sk_free(context->search_attributes); | 338 | sk_STORE_ATTR_INFO_free(context->search_attributes); |
| 332 | if (context) OPENSSL_free(context); | 339 | if (context) OPENSSL_free(context); |
| 333 | return 1; | 340 | return 1; |
| 334 | } | 341 | } |
| @@ -337,7 +344,8 @@ static int mem_list_endp(STORE *s, void *handle) | |||
| 337 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; | 344 | struct mem_ctx_st *context = (struct mem_ctx_st *)handle; |
| 338 | 345 | ||
| 339 | if (!context | 346 | if (!context |
| 340 | || context->search_index == sk_num(context->search_attributes)) | 347 | || context->search_index |
| 348 | == sk_STORE_ATTR_INFO_num(context->search_attributes)) | ||
| 341 | return 1; | 349 | return 1; |
| 342 | return 0; | 350 | return 0; |
| 343 | } | 351 | } |
