Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: openssl/crypto/store/str_mem.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/crypto/store/str_lib.c ('k') | openssl/crypto/symhacks.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* crypto/store/str_mem.c -*- mode:C; c-file-style: "eay" -*- */ 1 /* crypto/store/str_mem.c -*- mode:C; c-file-style: "eay" -*- */
2 /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 2 /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2003. 3 * project 2003.
4 */ 4 */
5 /* ==================================================================== 5 /* ====================================================================
6 * Copyright (c) 2003 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2003 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 This is currently provided for by sorting the entries by numbers that 69 This is currently provided for by sorting the entries by numbers that
70 are composed of bits set at the positions indicated by attribute type 70 are composed of bits set at the positions indicated by attribute type
71 codes. This provides for ranges determined by the highest attribute 71 codes. This provides for ranges determined by the highest attribute
72 type code value. A better idea might be to sort by values computed 72 type code value. A better idea might be to sort by values computed
73 from the range of attributes associated with the object (basically, 73 from the range of attributes associated with the object (basically,
74 the difference between the highest and lowest attribute type code) 74 the difference between the highest and lowest attribute type code)
75 and it's distance from a base (basically, the lowest associated 75 and it's distance from a base (basically, the lowest associated
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 mat ch 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);
106 static void mem_clean(STORE *s); 111 static void mem_clean(STORE *s);
107 static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type, 112 static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type,
108 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); 113 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
109 static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type, 114 static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type,
110 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); 115 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
111 static int mem_store(STORE *s, STORE_OBJECT_TYPES type, 116 static int mem_store(STORE *s, STORE_OBJECT_TYPES type,
112 STORE_OBJECT *data, OPENSSL_ITEM attributes[], 117 STORE_OBJECT *data, OPENSSL_ITEM attributes[],
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 { 238 {
234 STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB); 239 STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB);
235 goto err; 240 goto err;
236 } 241 }
237 242
238 while((attrs = STORE_parse_attrs_next(attribute_context))) 243 while((attrs = STORE_parse_attrs_next(attribute_context)))
239 { 244 {
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,
247 ERR_R_MALLOC_FAILURE); 252 ERR_R_MALLOC_FAILURE);
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;
255 STORE_parse_attrs_end(attribute_context); 260 STORE_parse_attrs_end(attribute_context);
256 context->search_index = -1; 261 context->search_index = -1;
257 context->index = -1; 262 context->index = -1;
258 return context; 263 return context;
259 err: 264 err:
260 if (attribute_context) STORE_parse_attrs_end(attribute_context); 265 if (attribute_context) STORE_parse_attrs_end(attribute_context);
261 mem_list_end(s, context); 266 mem_list_end(s, context);
(...skipping 15 matching lines...) Expand all
277 return NULL; 282 return NULL;
278 } 283 }
279 if (!store) 284 if (!store)
280 { 285 {
281 STOREerr(STORE_F_MEM_LIST_NEXT, STORE_R_NO_STORE); 286 STOREerr(STORE_F_MEM_LIST_NEXT, STORE_R_NO_STORE);
282 return NULL; 287 return NULL;
283 } 288 }
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_attr ibutes, 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 {
295 context->search_index = srch; 303 context->search_index = srch;
296 break; 304 break;
297 } 305 }
298 } 306 }
299 } 307 }
300 if (context->search_index < 0) 308 if (context->search_index < 0)
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_in fo)
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)->at tr_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)
322 { 329 {
323 struct mem_ctx_st *context = (struct mem_ctx_st *)handle; 330 struct mem_ctx_st *context = (struct mem_ctx_st *)handle;
324 331
325 if (!context) 332 if (!context)
326 { 333 {
327 STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER); 334 STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER);
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 }
335 static int mem_list_endp(STORE *s, void *handle) 342 static int mem_list_endp(STORE *s, void *handle)
336 { 343 {
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 }
344 static int mem_lock(STORE *s, OPENSSL_ITEM attributes[], 352 static int mem_lock(STORE *s, OPENSSL_ITEM attributes[],
345 OPENSSL_ITEM parameters[]) 353 OPENSSL_ITEM parameters[])
346 { 354 {
347 return 1; 355 return 1;
348 } 356 }
349 static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], 357 static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[],
350 OPENSSL_ITEM parameters[]) 358 OPENSSL_ITEM parameters[])
351 { 359 {
352 return 1; 360 return 1;
353 } 361 }
354 static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)) 362 static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void))
355 { 363 {
356 return 1; 364 return 1;
357 } 365 }
OLDNEW
« no previous file with comments | « openssl/crypto/store/str_lib.c ('k') | openssl/crypto/symhacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698