mirror of
https://github.com/openssl/openssl.git
synced 2025-01-30 14:01:55 +08:00
asn1: sort stacks before using find
a_strnid.c doesn't have a lock for the sort. This is no worse than the existing code which sorted silently without a lock. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> (Merged from https://github.com/openssl/openssl/pull/20842)
This commit is contained in:
parent
b5a635dc21
commit
0feb90ba60
@ -133,7 +133,9 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
|
||||
|
||||
fnd.nid = nid;
|
||||
if (stable) {
|
||||
if (stable != NULL) {
|
||||
/* Ideally, this would be done under lock */
|
||||
sk_ASN1_STRING_TABLE_sort(stable);
|
||||
idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
|
||||
if (idx >= 0)
|
||||
return sk_ASN1_STRING_TABLE_value(stable, idx);
|
||||
|
@ -679,7 +679,7 @@ static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio)
|
||||
char linebuf[MAX_SMLEN];
|
||||
MIME_HEADER *mhdr = NULL, *new_hdr = NULL;
|
||||
STACK_OF(MIME_HEADER) *headers;
|
||||
int len, state, save_state = 0;
|
||||
int i, len, state, save_state = 0;
|
||||
|
||||
headers = sk_MIME_HEADER_new(mime_hdr_cmp);
|
||||
if (headers == NULL)
|
||||
@ -785,6 +785,12 @@ static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio)
|
||||
break; /* Blank line means end of headers */
|
||||
}
|
||||
|
||||
/* Sort the headers and their params for faster searching */
|
||||
sk_MIME_HEADER_sort(headers);
|
||||
for (i = 0; i < sk_MIME_HEADER_num(headers); i++)
|
||||
if ((mhdr = sk_MIME_HEADER_value(headers, i)) != NULL
|
||||
&& mhdr->params != NULL)
|
||||
sk_MIME_PARAM_sort(mhdr->params);
|
||||
return headers;
|
||||
|
||||
err:
|
||||
|
Loading…
Reference in New Issue
Block a user