OpenCoverage

tasn_utl.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/tasn_utl.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it)-
3{-
4 int *sel = (void *)(((char *) *pval) + it->utype);-
5 return
executed 325287 times by 1 test: return *sel;
Executed by:
  • libcrypto.so.1.1
*sel;
executed 325287 times by 1 test: return *sel;
Executed by:
  • libcrypto.so.1.1
325287
6}-
7-
8-
9-
10-
11-
12int asn1_set_choice_selector(ASN1_VALUE **pval, int value,-
13 const ASN1_ITEM *it)-
14{-
15 int *sel, ret;-
16 sel = (void *)(((char *) *pval) + it->utype);-
17 ret = *sel;-
18 *sel = value;-
19 return
executed 349929 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 349929 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
349929
20}-
21int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)-
22{-
23 const ASN1_AUX *aux;-
24 CRYPTO_REF_COUNT *lck;-
25 CRYPTO_RWLOCK **lock;-
26 int ret = -1;-
27-
28 if ((
(it->itype != 0x1)Description
TRUEevaluated 101854 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3271981 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
it->itype != 0x1)
(it->itype != 0x1)Description
TRUEevaluated 101854 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3271981 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
101854-3271981
29 && (
(it->itype != 0x6)Description
TRUEnever evaluated
FALSEevaluated 101854 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
it->itype != 0x6)
(it->itype != 0x6)Description
TRUEnever evaluated
FALSEevaluated 101854 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-101854
30 return
never executed: return 0;
0;
never executed: return 0;
0
31 aux = it->funcs;-
32 if (!aux
!auxDescription
TRUEevaluated 2688219 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 685616 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| !(aux->flags & 1)
!(aux->flags & 1)Description
TRUEevaluated 488673 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 196943 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
196943-2688219
33 return
executed 3176892 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
0;
executed 3176892 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
3176892
34 lck = (void *)(((char *) *pval) + aux->ref_offset);-
35 lock = (void *)(((char *) *pval) + aux->ref_lock);-
36-
37 switch (op) {-
38 case
executed 80831 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
0:
executed 80831 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
80831
39 *lck = ret = 1;-
40 *lock = CRYPTO_THREAD_lock_new();-
41 if (*lock
*lock == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 80831 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
==
*lock == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 80831 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-80831
42 ((void *)0)
*lock == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 80831 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-80831
43 ) {-
44 ERR_put_error(13,(233),((1|64)),__FILE__,79);-
45 return
never executed: return -1;
-1;
never executed: return -1;
0
46 }-
47 break;
executed 80831 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
80831
48 case
never executed: case 1:
1:
never executed: case 1:
0
49 if (!CRYPTO_UP_REF(lck, &ret, *lock)
!CRYPTO_UP_REF..., &ret, *lock)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
50 return
never executed: return -1;
-1;
never executed: return -1;
0
51 break;
never executed: break;
0
52 case
executed 116112 times by 1 test: case -1:
Executed by:
  • libcrypto.so.1.1
-1:
executed 116112 times by 1 test: case -1:
Executed by:
  • libcrypto.so.1.1
116112
53 if (!CRYPTO_DOWN_REF(lck, &ret, *lock)
!CRYPTO_DOWN_R..., &ret, *lock)Description
TRUEnever evaluated
FALSEevaluated 116112 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-116112
54 return
never executed: return -1;
-1;
never executed: return -1;
0
55-
56-
57-
58 ;-
59 if (ret == 0
ret == 0Description
TRUEevaluated 80831 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 35281 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
35281-80831
60 CRYPTO_THREAD_lock_free(*lock);-
61 *lock = -
62 ((void *)0)-
63 ;-
64 }
executed 80831 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
80831
65 break;
executed 116112 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
116112
66 }-
67-
68 return
executed 196943 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 196943 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
196943
69}-
70-
71static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it)-
72{-
73 const ASN1_AUX *aux;-
74 if (!pval
!pvalDescription
TRUEnever evaluated
FALSEevaluated 5472365 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
|| !*pval
!*pvalDescription
TRUEnever evaluated
FALSEevaluated 5472365 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-5472365
75 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
76 ((void *)0)
never executed: return ((void *)0) ;
0
77 ;
never executed: return ((void *)0) ;
0
78 aux = it->funcs;-
79 if (!aux
!auxDescription
TRUEevaluated 4301377 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1170988 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| !(aux->flags & 2)
!(aux->flags & 2)Description
TRUEevaluated 758401 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 412587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
412587-4301377
80 return
executed 5059778 times by 2 tests: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
executed 5059778 times by 2 tests: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
5059778
81 ((void *)0)
executed 5059778 times by 2 tests: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
5059778
82 ;
executed 5059778 times by 2 tests: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
5059778
83 return
executed 412587 times by 1 test: return (void *)(((char *) *pval) + aux->enc_offset);
Executed by:
  • libcrypto.so.1.1
(void *)(((char *) *pval) + aux->enc_offset);
executed 412587 times by 1 test: return (void *)(((char *) *pval) + aux->enc_offset);
Executed by:
  • libcrypto.so.1.1
412587
84}-
85-
86void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it)-
87{-
88 ASN1_ENCODING *enc;-
89 enc = asn1_get_enc_ptr(pval, it);-
90 if (enc
encDescription
TRUEevaluated 89717 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1570271 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
89717-1570271
91 enc->enc = -
92 ((void *)0)-
93 ;-
94 enc->len = 0;-
95 enc->modified = 1;-
96 }
executed 89717 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
89717
97}
executed 1659988 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1659988
98-
99void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)-
100{-
101 ASN1_ENCODING *enc;-
102 enc = asn1_get_enc_ptr(pval, it);-
103 if (enc
encDescription
TRUEevaluated 89717 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1561266 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
) {
89717-1561266
104 CRYPTO_free(enc->enc, __FILE__, 131);-
105 enc->enc = -
106 ((void *)0)-
107 ;-
108 enc->len = 0;-
109 enc->modified = 1;-
110 }
executed 89717 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
89717
111}
executed 1650983 times by 2 tests: end of block
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1650983
112-
113int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,-
114 const ASN1_ITEM *it)-
115{-
116 ASN1_ENCODING *enc;-
117 enc = asn1_get_enc_ptr(pval, it);-
118 if (!enc
!encDescription
TRUEevaluated 882759 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 69204 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
69204-882759
119 return
executed 882759 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1;
executed 882759 times by 2 tests: return 1;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
882759
120-
121 CRYPTO_free(enc->enc, __FILE__, 146);-
122 if ((
(enc->enc = CR...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 69204 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
enc->enc = CRYPTO_malloc(inlen, __FILE__, 147)) ==
(enc->enc = CR...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 69204 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-69204
123 ((void *)0)
(enc->enc = CR...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 69204 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-69204
124 ) {-
125 ERR_put_error(13,(115),((1|64)),__FILE__,148);-
126 return
never executed: return 0;
0;
never executed: return 0;
0
127 }-
128 memcpy(enc->enc, in, inlen);-
129 enc->len = inlen;-
130 enc->modified = 0;-
131-
132 return
executed 69204 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 69204 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
69204
133}-
134-
135int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,-
136 const ASN1_ITEM *it)-
137{-
138 ASN1_ENCODING *enc;-
139 enc = asn1_get_enc_ptr(pval, it);-
140 if (!enc
!encDescription
TRUEevaluated 1045482 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 163949 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| enc->modified
enc->modifiedDescription
TRUEevaluated 124 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 163825 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
124-1045482
141 return
executed 1045606 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
0;
executed 1045606 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1045606
142 if (out
outDescription
TRUEevaluated 54587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 109238 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
54587-109238
143 memcpy(*out, enc->enc, enc->len);-
144 *out += enc->len;-
145 }
executed 54587 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
54587
146 if (len
lenDescription
TRUEevaluated 163825 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-163825
147 *
executed 163825 times by 1 test: *len = enc->len;
Executed by:
  • libcrypto.so.1.1
len = enc->len;
executed 163825 times by 1 test: *len = enc->len;
Executed by:
  • libcrypto.so.1.1
163825
148 return
executed 163825 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 163825 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
163825
149}-
150-
151-
152ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)-
153{-
154 ASN1_VALUE **pvaltmp;-
155 pvaltmp = (void *)(((char *) *pval) + tt->offset);-
156-
157-
158-
159-
160 return
executed 17774150 times by 2 tests: return pvaltmp;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
pvaltmp;
executed 17774150 times by 2 tests: return pvaltmp;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
17774150
161}-
162-
163-
164-
165-
166-
167-
168const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,-
169 int nullerr)-
170{-
171 const ASN1_ADB *adb;-
172 const ASN1_ADB_TABLE *atbl;-
173 long selector;-
174 ASN1_VALUE **sfld;-
175 int i;-
176 if (!(tt->flags & (0x3<<8))
!(tt->flags & (0x3<<8))Description
TRUEevaluated 11996246 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 105640 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
105640-11996246
177 return
executed 11996246 times by 2 tests: return tt;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
tt;
executed 11996246 times by 2 tests: return tt;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
11996246
178-
179-
180 adb = ((const ASN1_ADB *)(tt->item));-
181-
182-
183 sfld = (void *)(((char *) *pval) + adb->offset);-
184-
185-
186 if (*
*sfld == ((void *)0)Description
TRUEevaluated 43058 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 62582 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sfld ==
*sfld == ((void *)0)Description
TRUEevaluated 43058 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 62582 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
43058-62582
187 ((void *)0)
*sfld == ((void *)0)Description
TRUEevaluated 43058 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 62582 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
43058-62582
188 ) {-
189 if (!adb->null_tt
!adb->null_ttDescription
TRUEevaluated 43058 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-43058
190 goto
executed 43058 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 43058 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
43058
191 return
never executed: return adb->null_tt;
adb->null_tt;
never executed: return adb->null_tt;
0
192 }-
193-
194-
195-
196-
197-
198 if (tt->flags & (0x1<<8)
tt->flags & (0x1<<8)Description
TRUEevaluated 62582 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-62582
199 selector = OBJ_obj2nid((ASN1_OBJECT *)*sfld);
executed 62582 times by 1 test: selector = OBJ_obj2nid((ASN1_OBJECT *)*sfld);
Executed by:
  • libcrypto.so.1.1
62582
200 else-
201 selector = ASN1_INTEGER_get((ASN1_INTEGER *)*sfld);
never executed: selector = ASN1_INTEGER_get((ASN1_INTEGER *)*sfld);
0
202-
203-
204 if (adb->adb_cb !=
adb->adb_cb != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 62582 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-62582
205 ((void *)0)
adb->adb_cb != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 62582 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-62582
206 && adb->adb_cb(&selector) == 0
adb->adb_cb(&selector) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
207 ERR_put_error(13,(110),(164),__FILE__,226);-
208 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
209 ((void *)0)
never executed: return ((void *)0) ;
0
210 ;
never executed: return ((void *)0) ;
0
211 }-
212 for (atbl = adb->tbl, i = 0; i < adb->tblcount
i < adb->tblcountDescription
TRUEevaluated 283401 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 51098 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++, atbl++)
51098-283401
213 if (atbl->value == selector
atbl->value == selectorDescription
TRUEevaluated 11484 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 271917 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
11484-271917
214 return
executed 11484 times by 1 test: return &atbl->tt;
Executed by:
  • libcrypto.so.1.1
&atbl->tt;
executed 11484 times by 1 test: return &atbl->tt;
Executed by:
  • libcrypto.so.1.1
11484
215-
216-
217-
218-
219 if (!adb->default_tt
!adb->default_ttDescription
TRUEnever evaluated
FALSEevaluated 51098 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-51098
220 goto
never executed: goto err;
err;
never executed: goto err;
0
221 return
executed 51098 times by 1 test: return adb->default_tt;
Executed by:
  • libcrypto.so.1.1
adb->default_tt;
executed 51098 times by 1 test: return adb->default_tt;
Executed by:
  • libcrypto.so.1.1
51098
222-
223 err:-
224-
225 if (nullerr
nullerrDescription
TRUEnever evaluated
FALSEevaluated 43058 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-43058
226 ERR_put_error(13,(110),(164),__FILE__,251);
never executed: ERR_put_error(13,(110),(164),__FILE__,251);
0
227 return
executed 43058 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
executed 43058 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
43058
228 ((void *)0)
executed 43058 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
43058
229 ;
executed 43058 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
43058
230}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2