Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* crypto/x509/by_dir.c */ | 1 /* crypto/x509/by_dir.c */ |
| 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
| 6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
| 7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
| 8 * | 8 * |
| 9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
| 10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 X509_CINF st_x509_cinf; | 280 X509_CINF st_x509_cinf; |
| 281 } x509; | 281 } x509; |
| 282 struct { | 282 struct { |
| 283 X509_CRL st_crl; | 283 X509_CRL st_crl; |
| 284 X509_CRL_INFO st_crl_info; | 284 X509_CRL_INFO st_crl_info; |
| 285 } crl; | 285 } crl; |
| 286 } data; | 286 } data; |
| 287 int ok=0; | 287 int ok=0; |
| 288 int i,j,k; | 288 int i,j,k; |
| 289 unsigned long h; | 289 unsigned long h; |
| 290 unsigned long hash_array[2]; | |
| 291 int hash_index; | |
| 290 BUF_MEM *b=NULL; | 292 BUF_MEM *b=NULL; |
| 291 X509_OBJECT stmp,*tmp; | 293 X509_OBJECT stmp,*tmp; |
| 292 const char *postfix=""; | 294 const char *postfix=""; |
| 293 | 295 |
| 294 if (name == NULL) return(0); | 296 if (name == NULL) return(0); |
| 295 | 297 |
| 296 stmp.type=type; | 298 stmp.type=type; |
| 297 if (type == X509_LU_X509) | 299 if (type == X509_LU_X509) |
| 298 { | 300 { |
| 299 data.x509.st_x509.cert_info= &data.x509.st_x509_cinf; | 301 data.x509.st_x509.cert_info= &data.x509.st_x509_cinf; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 316 | 318 |
| 317 if ((b=BUF_MEM_new()) == NULL) | 319 if ((b=BUF_MEM_new()) == NULL) |
| 318 { | 320 { |
| 319 X509err(X509_F_GET_CERT_BY_SUBJECT,ERR_R_BUF_LIB); | 321 X509err(X509_F_GET_CERT_BY_SUBJECT,ERR_R_BUF_LIB); |
| 320 goto finish; | 322 goto finish; |
| 321 } | 323 } |
| 322 | 324 |
| 323 ctx=(BY_DIR *)xl->method_data; | 325 ctx=(BY_DIR *)xl->method_data; |
| 324 | 326 |
| 325 h=X509_NAME_hash(name); | 327 h=X509_NAME_hash(name); |
| 328 hash_array[0]=h; | |
|
Ryan Sleevi
2013/03/21 19:56:01
Why structured like this?
Why not
hash_array[0]=X
digit1
2013/03/21 21:23:31
That's not my code :-) I'll try to fix it nonethel
| |
| 329 hash_array[1]=X509_NAME_hash_old(name); | |
| 330 for (hash_index=0; hash_index < 2; hash_index++) | |
|
Ryan Sleevi
2013/03/21 19:56:01
++hash_index
wtc
2013/03/21 22:41:49
Our C++ Style Guide only recommends using the
pre-
agl
2013/03/22 13:52:36
Long ago, post incrementing STL iterators was less
| |
| 331 { | |
| 332 h=hash_array[hash_index]; | |
| 326 for (i=0; i < sk_BY_DIR_ENTRY_num(ctx->dirs); i++) | 333 for (i=0; i < sk_BY_DIR_ENTRY_num(ctx->dirs); i++) |
| 327 { | 334 { |
| 328 BY_DIR_ENTRY *ent; | 335 BY_DIR_ENTRY *ent; |
| 329 int idx; | 336 int idx; |
| 330 BY_DIR_HASH htmp, *hent; | 337 BY_DIR_HASH htmp, *hent; |
| 331 ent = sk_BY_DIR_ENTRY_value(ctx->dirs, i); | 338 ent = sk_BY_DIR_ENTRY_value(ctx->dirs, i); |
| 332 j=strlen(ent->dir)+1+8+6+1+1; | 339 j=strlen(ent->dir)+1+8+6+1+1; |
| 333 if (!BUF_MEM_grow(b,j)) | 340 if (!BUF_MEM_grow(b,j)) |
| 334 { | 341 { |
| 335 X509err(X509_F_GET_CERT_BY_SUBJECT,ERR_R_MALLOC_FAILURE) ; | 342 X509err(X509_F_GET_CERT_BY_SUBJECT,ERR_R_MALLOC_FAILURE) ; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 ret->type=tmp->type; | 476 ret->type=tmp->type; |
| 470 memcpy(&ret->data,&tmp->data,sizeof(ret->data)); | 477 memcpy(&ret->data,&tmp->data,sizeof(ret->data)); |
| 471 /* If we were going to up the reference count, | 478 /* If we were going to up the reference count, |
| 472 * we would need to do it on a perl 'type' | 479 * we would need to do it on a perl 'type' |
| 473 * basis */ | 480 * basis */ |
| 474 /* CRYPTO_add(&tmp->data.x509->references,1, | 481 /* CRYPTO_add(&tmp->data.x509->references,1, |
| 475 CRYPTO_LOCK_X509);*/ | 482 CRYPTO_LOCK_X509);*/ |
| 476 goto finish; | 483 goto finish; |
| 477 } | 484 } |
| 478 } | 485 } |
| 486 } | |
| 479 finish: | 487 finish: |
| 480 if (b != NULL) BUF_MEM_free(b); | 488 if (b != NULL) BUF_MEM_free(b); |
| 481 return(ok); | 489 return(ok); |
| 482 } | 490 } |
| OLD | NEW |