| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509v3/v3_pmaps.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||
| 2 | * Copyright 2003-2016 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||
| 3 | * | - | ||||||||||||
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||
| 5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||
| 6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||
| 7 | * https://www.openssl.org/source/license.html | - | ||||||||||||
| 8 | */ | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | #include <stdio.h> | - | ||||||||||||
| 11 | #include "internal/cryptlib.h" | - | ||||||||||||
| 12 | #include <openssl/asn1t.h> | - | ||||||||||||
| 13 | #include <openssl/conf.h> | - | ||||||||||||
| 14 | #include <openssl/x509v3.h> | - | ||||||||||||
| 15 | #include "ext_dat.h" | - | ||||||||||||
| 16 | - | |||||||||||||
| 17 | static void *v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method, | - | ||||||||||||
| 18 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); | - | ||||||||||||
| 19 | static STACK_OF(CONF_VALUE) *i2v_POLICY_MAPPINGS(const X509V3_EXT_METHOD | - | ||||||||||||
| 20 | *method, void *pmps, STACK_OF(CONF_VALUE) | - | ||||||||||||
| 21 | *extlist); | - | ||||||||||||
| 22 | - | |||||||||||||
| 23 | const X509V3_EXT_METHOD v3_policy_mappings = { | - | ||||||||||||
| 24 | NID_policy_mappings, 0, | - | ||||||||||||
| 25 | ASN1_ITEM_ref(POLICY_MAPPINGS), | - | ||||||||||||
| 26 | 0, 0, 0, 0, | - | ||||||||||||
| 27 | 0, 0, | - | ||||||||||||
| 28 | i2v_POLICY_MAPPINGS, | - | ||||||||||||
| 29 | v2i_POLICY_MAPPINGS, | - | ||||||||||||
| 30 | 0, 0, | - | ||||||||||||
| 31 | NULL | - | ||||||||||||
| 32 | }; | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | ASN1_SEQUENCE(POLICY_MAPPING) = { | - | ||||||||||||
| 35 | ASN1_SIMPLE(POLICY_MAPPING, issuerDomainPolicy, ASN1_OBJECT), | - | ||||||||||||
| 36 | ASN1_SIMPLE(POLICY_MAPPING, subjectDomainPolicy, ASN1_OBJECT) | - | ||||||||||||
| 37 | } ASN1_SEQUENCE_END(POLICY_MAPPING) | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | ASN1_ITEM_TEMPLATE(POLICY_MAPPINGS) = | - | ||||||||||||
| 40 | ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, POLICY_MAPPINGS, | - | ||||||||||||
| 41 | POLICY_MAPPING) | - | ||||||||||||
| 42 | ASN1_ITEM_TEMPLATE_END(POLICY_MAPPINGS) | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | IMPLEMENT_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) never executed: end of blocknever executed: return (POLICY_MAPPING *)ASN1_item_new((&(POLICY_MAPPING_it))); | 0 | ||||||||||||
| 45 | - | |||||||||||||
| 46 | static STACK_OF(CONF_VALUE) *i2v_POLICY_MAPPINGS(const X509V3_EXT_METHOD | - | ||||||||||||
| 47 | *method, void *a, STACK_OF(CONF_VALUE) | - | ||||||||||||
| 48 | *ext_list) | - | ||||||||||||
| 49 | { | - | ||||||||||||
| 50 | POLICY_MAPPINGS *pmaps = a; | - | ||||||||||||
| 51 | POLICY_MAPPING *pmap; | - | ||||||||||||
| 52 | int i; | - | ||||||||||||
| 53 | char obj_tmp1[80]; | - | ||||||||||||
| 54 | char obj_tmp2[80]; | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | for (i = 0; i < sk_POLICY_MAPPING_num(pmaps); i++) {
| 548-572 | ||||||||||||
| 57 | pmap = sk_POLICY_MAPPING_value(pmaps, i); | - | ||||||||||||
| 58 | i2t_ASN1_OBJECT(obj_tmp1, 80, pmap->issuerDomainPolicy); | - | ||||||||||||
| 59 | i2t_ASN1_OBJECT(obj_tmp2, 80, pmap->subjectDomainPolicy); | - | ||||||||||||
| 60 | X509V3_add_value(obj_tmp1, obj_tmp2, &ext_list); | - | ||||||||||||
| 61 | } executed 572 times by 1 test: end of blockExecuted by:
| 572 | ||||||||||||
| 62 | return ext_list; executed 548 times by 1 test: return ext_list;Executed by:
| 548 | ||||||||||||
| 63 | } | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | static void *v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method, | - | ||||||||||||
| 66 | X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) | - | ||||||||||||
| 67 | { | - | ||||||||||||
| 68 | POLICY_MAPPING *pmap = NULL; | - | ||||||||||||
| 69 | ASN1_OBJECT *obj1 = NULL, *obj2 = NULL; | - | ||||||||||||
| 70 | CONF_VALUE *val; | - | ||||||||||||
| 71 | POLICY_MAPPINGS *pmaps; | - | ||||||||||||
| 72 | const int num = sk_CONF_VALUE_num(nval); | - | ||||||||||||
| 73 | int i; | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | if ((pmaps = sk_POLICY_MAPPING_new_reserve(NULL, num)) == NULL) {
| 0 | ||||||||||||
| 76 | X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 77 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 78 | } | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | for (i = 0; i < num; i++) {
| 0 | ||||||||||||
| 81 | val = sk_CONF_VALUE_value(nval, i); | - | ||||||||||||
| 82 | if (!val->value || !val->name) {
| 0 | ||||||||||||
| 83 | X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, | - | ||||||||||||
| 84 | X509V3_R_INVALID_OBJECT_IDENTIFIER); | - | ||||||||||||
| 85 | X509V3_conf_err(val); | - | ||||||||||||
| 86 | goto err; never executed: goto err; | 0 | ||||||||||||
| 87 | } | - | ||||||||||||
| 88 | obj1 = OBJ_txt2obj(val->name, 0); | - | ||||||||||||
| 89 | obj2 = OBJ_txt2obj(val->value, 0); | - | ||||||||||||
| 90 | if (!obj1 || !obj2) {
| 0 | ||||||||||||
| 91 | X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, | - | ||||||||||||
| 92 | X509V3_R_INVALID_OBJECT_IDENTIFIER); | - | ||||||||||||
| 93 | X509V3_conf_err(val); | - | ||||||||||||
| 94 | goto err; never executed: goto err; | 0 | ||||||||||||
| 95 | } | - | ||||||||||||
| 96 | pmap = POLICY_MAPPING_new(); | - | ||||||||||||
| 97 | if (pmap == NULL) {
| 0 | ||||||||||||
| 98 | X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 99 | goto err; never executed: goto err; | 0 | ||||||||||||
| 100 | } | - | ||||||||||||
| 101 | pmap->issuerDomainPolicy = obj1; | - | ||||||||||||
| 102 | pmap->subjectDomainPolicy = obj2; | - | ||||||||||||
| 103 | obj1 = obj2 = NULL; | - | ||||||||||||
| 104 | sk_POLICY_MAPPING_push(pmaps, pmap); /* no failure as it was reserved */ | - | ||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||
| 106 | return pmaps; never executed: return pmaps; | 0 | ||||||||||||
| 107 | err: | - | ||||||||||||
| 108 | ASN1_OBJECT_free(obj1); | - | ||||||||||||
| 109 | ASN1_OBJECT_free(obj2); | - | ||||||||||||
| 110 | sk_POLICY_MAPPING_pop_free(pmaps, POLICY_MAPPING_free); | - | ||||||||||||
| 111 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 112 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |