OpenCoverage

tasn_new.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/tasn_new.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2000-2018 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 <stddef.h>-
11#include <openssl/asn1.h>-
12#include <openssl/objects.h>-
13#include <openssl/err.h>-
14#include <openssl/asn1t.h>-
15#include <string.h>-
16#include "asn1_locl.h"-
17-
18static int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it,-
19 int embed);-
20static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it,-
21 int embed);-
22static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);-
23static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);-
24static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);-
25static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);-
26-
27ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it)-
28{-
29 ASN1_VALUE *ret = NULL;-
30 if (ASN1_item_ex_new(&ret, it) > 0)
ASN1_item_ex_new(&ret, it) > 0Description
TRUEevaluated 368142 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-368142
31 return ret;
executed 368142 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
368142
32 return NULL;
never executed: return ((void *)0) ;
0
33}-
34-
35/* Allocate an ASN1 structure */-
36-
37int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it)-
38{-
39 return asn1_item_embed_new(pval, it, 0);
executed 1520094 times by 2 tests: return asn1_item_embed_new(pval, it, 0);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1520094
40}-
41-
42int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)-
43{-
44 const ASN1_TEMPLATE *tt = NULL;-
45 const ASN1_EXTERN_FUNCS *ef;-
46 const ASN1_AUX *aux = it->funcs;-
47 ASN1_aux_cb *asn1_cb;-
48 ASN1_VALUE **pseqval;-
49 int i;-
50 if (aux && aux->asn1_cb)
auxDescription
TRUEevaluated 637556 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 3886273 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
aux->asn1_cbDescription
TRUEevaluated 440704 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 196852 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
196852-3886273
51 asn1_cb = aux->asn1_cb;
executed 440704 times by 2 tests: asn1_cb = aux->asn1_cb;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
440704
52 else-
53 asn1_cb = 0;
executed 4083125 times by 2 tests: asn1_cb = 0;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4083125
54-
55#ifndef OPENSSL_NO_CRYPTO_MDEBUG-
56 OPENSSL_mem_debug_push(it->sname ? it->sname : "asn1_item_embed_new");-
57#endif-
58-
59 switch (it->itype) {-
60-
61 case ASN1_ITYPE_EXTERN:
executed 151109 times by 1 test: case 0x4:
Executed by:
  • libcrypto.so.1.1
151109
62 ef = it->funcs;-
63 if (ef && ef->asn1_ex_new) {
efDescription
TRUEevaluated 151109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
ef->asn1_ex_newDescription
TRUEevaluated 151109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-151109
64 if (!ef->asn1_ex_new(pval, it))
!ef->asn1_ex_new(pval, it)Description
TRUEnever evaluated
FALSEevaluated 151109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-151109
65 goto memerr;
never executed: goto memerr;
0
66 }
executed 151109 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
151109
67 break;
executed 151109 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
151109
68-
69 case ASN1_ITYPE_PRIMITIVE:
executed 2016582 times by 2 tests: case 0x0:
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
2016582
70 if (it->templates) {
it->templatesDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2016581 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
1-2016581
71 if (!asn1_template_new(pval, it->templates))
!asn1_template...it->templates)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
72 goto memerr;
never executed: goto memerr;
0
73 } else if (!asn1_primitive_new(pval, it, embed))
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
!asn1_primitiv...al, it, embed)Description
TRUEnever evaluated
FALSEevaluated 2016581 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-2016581
74 goto memerr;
never executed: goto memerr;
0
75 break;
executed 2016582 times by 2 tests: break;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
2016582
76-
77 case ASN1_ITYPE_MSTRING:
executed 427413 times by 1 test: case 0x5:
Executed by:
  • libcrypto.so.1.1
427413
78 if (!asn1_primitive_new(pval, it, embed))
!asn1_primitiv...al, it, embed)Description
TRUEnever evaluated
FALSEevaluated 427413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-427413
79 goto memerr;
never executed: goto memerr;
0
80 break;
executed 427413 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
427413
81-
82 case ASN1_ITYPE_CHOICE:
executed 221755 times by 1 test: case 0x2:
Executed by:
  • libcrypto.so.1.1
221755
83 if (asn1_cb) {
asn1_cbDescription
TRUEevaluated 32587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 189168 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
32587-189168
84 i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);-
85 if (!i)
!iDescription
TRUEnever evaluated
FALSEevaluated 32587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-32587
86 goto auxerr;
never executed: goto auxerr;
0
87 if (i == 2) {
i == 2Description
TRUEnever evaluated
FALSEevaluated 32587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-32587
88#ifndef OPENSSL_NO_CRYPTO_MDEBUG-
89 OPENSSL_mem_debug_pop();-
90#endif-
91 return 1;
never executed: return 1;
0
92 }-
93 }
executed 32587 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
32587
94 if (embed) {
embedDescription
TRUEevaluated 5986 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 215769 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5986-215769
95 memset(*pval, 0, it->size);-
96 } else {
executed 5986 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5986
97 *pval = OPENSSL_zalloc(it->size);-
98 if (*pval == NULL)
*pval == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 215769 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-215769
99 goto memerr;
never executed: goto memerr;
0
100 }
executed 215769 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
215769
101 asn1_set_choice_selector(pval, -1, it);-
102 if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
asn1_cbDescription
TRUEevaluated 32587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 189168 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!asn1_cb(1, pv... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 32587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-189168
103 goto auxerr2;
never executed: goto auxerr2;
0
104 break;
executed 221755 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
221755
105-
106 case ASN1_ITYPE_NDEF_SEQUENCE:
executed 50927 times by 1 test: case 0x6:
Executed by:
  • libcrypto.so.1.1
50927
107 case ASN1_ITYPE_SEQUENCE:
executed 1656043 times by 2 tests: case 0x1:
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1656043
108 if (asn1_cb) {
asn1_cbDescription
TRUEevaluated 312615 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1394355 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
312615-1394355
109 i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);-
110 if (!i)
!iDescription
TRUEnever evaluated
FALSEevaluated 312615 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-312615
111 goto auxerr;
never executed: goto auxerr;
0
112 if (i == 2) {
i == 2Description
TRUEevaluated 46982 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 265633 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
46982-265633
113#ifndef OPENSSL_NO_CRYPTO_MDEBUG-
114 OPENSSL_mem_debug_pop();-
115#endif-
116 return 1;
executed 46982 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
46982
117 }-
118 }
executed 265633 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
265633
119 if (embed) {
embedDescription
TRUEevaluated 312117 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1347871 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
312117-1347871
120 memset(*pval, 0, it->size);-
121 } else {
executed 312117 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
312117
122 *pval = OPENSSL_zalloc(it->size);-
123 if (*pval == NULL)
*pval == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1347871 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-1347871
124 goto memerr;
never executed: goto memerr;
0
125 }
executed 1347871 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1347871
126 /* 0 : init. lock */-
127 if (asn1_do_lock(pval, 0, it) < 0) {
asn1_do_lock(pval, 0, it) < 0Description
TRUEnever evaluated
FALSEevaluated 1659988 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-1659988
128 if (!embed) {
!embedDescription
TRUEnever evaluated
FALSEnever evaluated
0
129 OPENSSL_free(*pval);-
130 *pval = NULL;-
131 }
never executed: end of block
0
132 goto memerr;
never executed: goto memerr;
0
133 }-
134 asn1_enc_init(pval, it);-
135 for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
i < it->tcountDescription
TRUEevaluated 4864787 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1659988 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
1659988-4864787
136 pseqval = asn1_get_field_ptr(pval, tt);-
137 if (!asn1_template_new(pseqval, tt))
!asn1_template...w(pseqval, tt)Description
TRUEnever evaluated
FALSEevaluated 4864787 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-4864787
138 goto memerr2;
never executed: goto memerr2;
0
139 }
executed 4864787 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4864787
140 if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
asn1_cbDescription
TRUEevaluated 265633 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1394355 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
!asn1_cb(1, pv... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 265633 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1394355
141 goto auxerr2;
never executed: goto auxerr2;
0
142 break;
executed 1659988 times by 2 tests: break;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1659988
143 }-
144#ifndef OPENSSL_NO_CRYPTO_MDEBUG-
145 OPENSSL_mem_debug_pop();-
146#endif-
147 return 1;
executed 4476847 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
4476847
148-
149 memerr2:-
150 asn1_item_embed_free(pval, it, embed);-
151 memerr:
code before this statement never executed: memerr:
0
152 ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ERR_R_MALLOC_FAILURE);-
153#ifndef OPENSSL_NO_CRYPTO_MDEBUG-
154 OPENSSL_mem_debug_pop();-
155#endif-
156 return 0;
never executed: return 0;
0
157-
158 auxerr2:-
159 asn1_item_embed_free(pval, it, embed);-
160 auxerr:
code before this statement never executed: auxerr:
0
161 ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ASN1_R_AUX_ERROR);-
162#ifndef OPENSSL_NO_CRYPTO_MDEBUG-
163 OPENSSL_mem_debug_pop();-
164#endif-
165 return 0;
never executed: return 0;
0
166-
167}-
168-
169static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)-
170{-
171 const ASN1_EXTERN_FUNCS *ef;-
172-
173 switch (it->itype) {-
174-
175 case ASN1_ITYPE_EXTERN:
never executed: case 0x4:
0
176 ef = it->funcs;-
177 if (ef && ef->asn1_ex_clear)
efDescription
TRUEnever evaluated
FALSEnever evaluated
ef->asn1_ex_clearDescription
TRUEnever evaluated
FALSEnever evaluated
0
178 ef->asn1_ex_clear(pval, it);
never executed: ef->asn1_ex_clear(pval, it);
0
179 else-
180 *pval = NULL;
never executed: *pval = ((void *)0) ;
0
181 break;
never executed: break;
0
182-
183 case ASN1_ITYPE_PRIMITIVE:
executed 1252222 times by 1 test: case 0x0:
Executed by:
  • libcrypto.so.1.1
1252222
184 if (it->templates)
it->templatesDescription
TRUEnever evaluated
FALSEevaluated 1252222 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1252222
185 asn1_template_clear(pval, it->templates);
never executed: asn1_template_clear(pval, it->templates);
0
186 else-
187 asn1_primitive_clear(pval, it);
executed 1252222 times by 1 test: asn1_primitive_clear(pval, it);
Executed by:
  • libcrypto.so.1.1
1252222
188 break;
executed 1252222 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
1252222
189-
190 case ASN1_ITYPE_MSTRING:
executed 67411 times by 1 test: case 0x5:
Executed by:
  • libcrypto.so.1.1
67411
191 asn1_primitive_clear(pval, it);-
192 break;
executed 67411 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
67411
193-
194 case ASN1_ITYPE_CHOICE:
executed 75605 times by 1 test: case 0x2:
Executed by:
  • libcrypto.so.1.1
75605
195 case ASN1_ITYPE_SEQUENCE:
executed 52755 times by 1 test: case 0x1:
Executed by:
  • libcrypto.so.1.1
52755
196 case ASN1_ITYPE_NDEF_SEQUENCE:
executed 2962 times by 1 test: case 0x6:
Executed by:
  • libcrypto.so.1.1
2962
197 *pval = NULL;-
198 break;
executed 131322 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
131322
199 }-
200}
executed 1450955 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1450955
201-
202static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)-
203{-
204 const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item);-
205 int embed = tt->flags & ASN1_TFLG_EMBED;-
206 ASN1_VALUE *tval;-
207 int ret;-
208 if (embed) {
embedDescription
TRUEevaluated 772994 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4091794 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
772994-4091794
209 tval = (ASN1_VALUE *)pval;-
210 pval = &tval;-
211 }
executed 772994 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
772994
212 if (tt->flags & ASN1_TFLG_OPTIONAL) {
tt->flags & (0x1)Description
TRUEevaluated 1745970 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3118818 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
1745970-3118818
213 asn1_template_clear(pval, tt);-
214 return 1;
executed 1745970 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1745970
215 }-
216 /* If ANY DEFINED BY nothing to do */-
217-
218 if (tt->flags & ASN1_TFLG_ADB_MASK) {
tt->flags & (0x3<<8)Description
TRUEevaluated 48005 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3070813 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
48005-3070813
219 *pval = NULL;-
220 return 1;
executed 48005 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
48005
221 }-
222#ifndef OPENSSL_NO_CRYPTO_MDEBUG-
223 OPENSSL_mem_debug_push(tt->field_name-
224 ? tt->field_name : "asn1_template_new");-
225#endif-
226 /* If SET OF or SEQUENCE OF, its a STACK */-
227 if (tt->flags & ASN1_TFLG_SK_MASK) {
tt->flags & (0x3 << 1)Description
TRUEevaluated 67078 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3003735 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
67078-3003735
228 STACK_OF(ASN1_VALUE) *skval;-
229 skval = sk_ASN1_VALUE_new_null();-
230 if (!skval) {
!skvalDescription
TRUEnever evaluated
FALSEevaluated 67078 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-67078
231 ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE);-
232 ret = 0;-
233 goto done;
never executed: goto done;
0
234 }-
235 *pval = (ASN1_VALUE *)skval;-
236 ret = 1;-
237 goto done;
executed 67078 times by 1 test: goto done;
Executed by:
  • libcrypto.so.1.1
67078
238 }-
239 /* Otherwise pass it back to the item routine */-
240 ret = asn1_item_embed_new(pval, it, embed);-
241 done:
code before this statement executed 3003735 times by 2 tests: done:
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3003735
242#ifndef OPENSSL_NO_CRYPTO_MDEBUG-
243 OPENSSL_mem_debug_pop();-
244#endif-
245 return ret;
executed 3070813 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3070813
246}-
247-
248static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)-
249{-
250 /* If ADB or STACK just NULL the field */-
251 if (tt->flags & (ASN1_TFLG_ADB_MASK | ASN1_TFLG_SK_MASK))
tt->flags & ((... | (0x3 << 1))Description
TRUEevaluated 295015 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1450955 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
295015-1450955
252 *pval = NULL;
executed 295015 times by 1 test: *pval = ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
295015
253 else-
254 asn1_item_clear(pval, ASN1_ITEM_ptr(tt->item));
executed 1450955 times by 1 test: asn1_item_clear(pval, (tt->item));
Executed by:
  • libcrypto.so.1.1
1450955
255}-
256-
257/*-
258 * NB: could probably combine most of the real XXX_new() behaviour and junk-
259 * all the old functions.-
260 */-
261-
262static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it,-
263 int embed)-
264{-
265 ASN1_TYPE *typ;-
266 ASN1_STRING *str;-
267 int utype;-
268-
269 if (!it)
!itDescription
TRUEnever evaluated
FALSEevaluated 2443994 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-2443994
270 return 0;
never executed: return 0;
0
271-
272 if (it->funcs) {
it->funcsDescription
TRUEevaluated 95502 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 2348492 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
95502-2348492
273 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;-
274 if (embed) {
embedDescription
TRUEevaluated 41973 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 53529 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
41973-53529
275 if (pf->prim_clear) {
pf->prim_clearDescription
TRUEevaluated 41973 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-41973
276 pf->prim_clear(pval, it);-
277 return 1;
executed 41973 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
41973
278 }-
279 } else if (pf->prim_new) {
never executed: end of block
pf->prim_newDescription
TRUEevaluated 53529 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-53529
280 return pf->prim_new(pval, it);
executed 53529 times by 2 tests: return pf->prim_new(pval, it);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
53529
281 }-
282 }
never executed: end of block
0
283-
284 if (it->itype == ASN1_ITYPE_MSTRING)
it->itype == 0x5Description
TRUEevaluated 427413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1921079 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
427413-1921079
285 utype = -1;
executed 427413 times by 1 test: utype = -1;
Executed by:
  • libcrypto.so.1.1
427413
286 else-
287 utype = it->utype;
executed 1921079 times by 2 tests: utype = it->utype;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1921079
288 switch (utype) {-
289 case V_ASN1_OBJECT:
executed 933921 times by 1 test: case 6:
Executed by:
  • libcrypto.so.1.1
933921
290 *pval = (ASN1_VALUE *)OBJ_nid2obj(NID_undef);-
291 return 1;
executed 933921 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
933921
292-
293 case V_ASN1_BOOLEAN:
executed 232 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
232
294 *(ASN1_BOOLEAN *)pval = it->size;-
295 return 1;
executed 232 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
232
296-
297 case V_ASN1_NULL:
executed 2 times by 1 test: case 5:
Executed by:
  • libcrypto.so.1.1
2
298 *pval = (ASN1_VALUE *)1;-
299 return 1;
executed 2 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
2
300-
301 case V_ASN1_ANY:
executed 237207 times by 1 test: case -4:
Executed by:
  • libcrypto.so.1.1
237207
302 if ((typ = OPENSSL_malloc(sizeof(*typ))) == NULL) {
(typ = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 237207 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-237207
303 ASN1err(ASN1_F_ASN1_PRIMITIVE_NEW, ERR_R_MALLOC_FAILURE);-
304 return 0;
never executed: return 0;
0
305 }-
306 typ->value.ptr = NULL;-
307 typ->type = -1;-
308 *pval = (ASN1_VALUE *)typ;-
309 break;
executed 237207 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
237207
310-
311 default:
executed 1177130 times by 2 tests: default:
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1177130
312 if (embed) {
embedDescription
TRUEevaluated 373108 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 804022 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
373108-804022
313 str = *(ASN1_STRING **)pval;-
314 memset(str, 0, sizeof(*str));-
315 str->type = utype;-
316 str->flags = ASN1_STRING_FLAG_EMBED;-
317 } else {
executed 373108 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
373108
318 str = ASN1_STRING_type_new(utype);-
319 *pval = (ASN1_VALUE *)str;-
320 }
executed 804022 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
804022
321 if (it->itype == ASN1_ITYPE_MSTRING && str)
it->itype == 0x5Description
TRUEevaluated 427413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 749717 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
strDescription
TRUEevaluated 427413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-749717
322 str->flags |= ASN1_STRING_FLAG_MSTRING;
executed 427413 times by 1 test: str->flags |= 0x040;
Executed by:
  • libcrypto.so.1.1
427413
323 break;
executed 1177130 times by 2 tests: break;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1177130
324 }-
325 if (*pval)
*pvalDescription
TRUEevaluated 1414337 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-1414337
326 return 1;
executed 1414337 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1414337
327 return 0;
never executed: return 0;
0
328}-
329-
330static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)-
331{-
332 int utype;-
333 if (it && it->funcs) {
itDescription
TRUEevaluated 1319633 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
it->funcsDescription
TRUEevaluated 45001 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1274632 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1319633
334 const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;-
335 if (pf->prim_clear)
pf->prim_clearDescription
TRUEevaluated 39856 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5145 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5145-39856
336 pf->prim_clear(pval, it);
executed 39856 times by 1 test: pf->prim_clear(pval, it);
Executed by:
  • libcrypto.so.1.1
39856
337 else-
338 *pval = NULL;
executed 5145 times by 1 test: *pval = ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
5145
339 return;
executed 45001 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
45001
340 }-
341 if (!it || (it->itype == ASN1_ITYPE_MSTRING))
!itDescription
TRUEnever evaluated
FALSEevaluated 1274632 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(it->itype == 0x5)Description
TRUEevaluated 67411 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1207221 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1274632
342 utype = -1;
executed 67411 times by 1 test: utype = -1;
Executed by:
  • libcrypto.so.1.1
67411
343 else-
344 utype = it->utype;
executed 1207221 times by 1 test: utype = it->utype;
Executed by:
  • libcrypto.so.1.1
1207221
345 if (utype == V_ASN1_BOOLEAN)
utype == 1Description
TRUEevaluated 367682 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 906950 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
367682-906950
346 *(ASN1_BOOLEAN *)pval = it->size;
executed 367682 times by 1 test: *(ASN1_BOOLEAN *)pval = it->size;
Executed by:
  • libcrypto.so.1.1
367682
347 else-
348 *pval = NULL;
executed 906950 times by 1 test: *pval = ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
906950
349}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2