Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/tasn_enc.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 <string.h> | - | ||||||||||||
12 | #include "internal/cryptlib.h" | - | ||||||||||||
13 | #include <openssl/asn1.h> | - | ||||||||||||
14 | #include <openssl/asn1t.h> | - | ||||||||||||
15 | #include <openssl/objects.h> | - | ||||||||||||
16 | #include "internal/asn1_int.h" | - | ||||||||||||
17 | #include "asn1_locl.h" | - | ||||||||||||
18 | - | |||||||||||||
19 | static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, | - | ||||||||||||
20 | const ASN1_ITEM *it, int tag, int aclass); | - | ||||||||||||
21 | static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, | - | ||||||||||||
22 | int skcontlen, const ASN1_ITEM *item, | - | ||||||||||||
23 | int do_sort, int iclass); | - | ||||||||||||
24 | static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | - | ||||||||||||
25 | const ASN1_TEMPLATE *tt, int tag, int aclass); | - | ||||||||||||
26 | static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, | - | ||||||||||||
27 | const ASN1_ITEM *it, int flags); | - | ||||||||||||
28 | static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, | - | ||||||||||||
29 | const ASN1_ITEM *it); | - | ||||||||||||
30 | - | |||||||||||||
31 | /* | - | ||||||||||||
32 | * Top level i2d equivalents: the 'ndef' variant instructs the encoder to use | - | ||||||||||||
33 | * indefinite length constructed encoding, where appropriate | - | ||||||||||||
34 | */ | - | ||||||||||||
35 | - | |||||||||||||
36 | int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, | - | ||||||||||||
37 | const ASN1_ITEM *it) | - | ||||||||||||
38 | { | - | ||||||||||||
39 | return asn1_item_flags_i2d(val, out, it, ASN1_TFLG_NDEF); executed 180 times by 1 test: return asn1_item_flags_i2d(val, out, it, (0x1<<11)); Executed by:
| 180 | ||||||||||||
40 | } | - | ||||||||||||
41 | - | |||||||||||||
42 | int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it) | - | ||||||||||||
43 | { | - | ||||||||||||
44 | return asn1_item_flags_i2d(val, out, it, 0); executed 137929 times by 2 tests: return asn1_item_flags_i2d(val, out, it, 0); Executed by:
| 137929 | ||||||||||||
45 | } | - | ||||||||||||
46 | - | |||||||||||||
47 | /* | - | ||||||||||||
48 | * Encode an ASN1 item, this is use by the standard 'i2d' function. 'out' | - | ||||||||||||
49 | * points to a buffer to output the data to. The new i2d has one additional | - | ||||||||||||
50 | * feature. If the output buffer is NULL (i.e. *out == NULL) then a buffer is | - | ||||||||||||
51 | * allocated and populated with the encoding. | - | ||||||||||||
52 | */ | - | ||||||||||||
53 | - | |||||||||||||
54 | static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, | - | ||||||||||||
55 | const ASN1_ITEM *it, int flags) | - | ||||||||||||
56 | { | - | ||||||||||||
57 | if (out && !*out) {
| 10797-121463 | ||||||||||||
58 | unsigned char *p, *buf; | - | ||||||||||||
59 | int len; | - | ||||||||||||
60 | - | |||||||||||||
61 | len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags); | - | ||||||||||||
62 | if (len <= 0)
| 10-110656 | ||||||||||||
63 | return len; executed 10 times by 1 test: return len; Executed by:
| 10 | ||||||||||||
64 | if ((buf = OPENSSL_malloc(len)) == NULL) {
| 0-110656 | ||||||||||||
65 | ASN1err(ASN1_F_ASN1_ITEM_FLAGS_I2D, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
66 | return -1; never executed: return -1; | 0 | ||||||||||||
67 | } | - | ||||||||||||
68 | p = buf; | - | ||||||||||||
69 | ASN1_item_ex_i2d(&val, &p, it, -1, flags); | - | ||||||||||||
70 | *out = buf; | - | ||||||||||||
71 | return len; executed 110656 times by 1 test: return len; Executed by:
| 110656 | ||||||||||||
72 | } | - | ||||||||||||
73 | - | |||||||||||||
74 | return ASN1_item_ex_i2d(&val, out, it, -1, flags); executed 27443 times by 2 tests: return ASN1_item_ex_i2d(&val, out, it, -1, flags); Executed by:
| 27443 | ||||||||||||
75 | } | - | ||||||||||||
76 | - | |||||||||||||
77 | /* | - | ||||||||||||
78 | * Encode an item, taking care of IMPLICIT tagging (if any). This function | - | ||||||||||||
79 | * performs the normal item handling: it can be used in external types. | - | ||||||||||||
80 | */ | - | ||||||||||||
81 | - | |||||||||||||
82 | int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | - | ||||||||||||
83 | const ASN1_ITEM *it, int tag, int aclass) | - | ||||||||||||
84 | { | - | ||||||||||||
85 | const ASN1_TEMPLATE *tt = NULL; | - | ||||||||||||
86 | int i, seqcontlen, seqlen, ndef = 1; | - | ||||||||||||
87 | const ASN1_EXTERN_FUNCS *ef; | - | ||||||||||||
88 | const ASN1_AUX *aux = it->funcs; | - | ||||||||||||
89 | ASN1_aux_cb *asn1_cb = 0; | - | ||||||||||||
90 | - | |||||||||||||
91 | if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)
| 37110-2978213 | ||||||||||||
92 | return 0; executed 37110 times by 1 test: return 0; Executed by:
| 37110 | ||||||||||||
93 | - | |||||||||||||
94 | if (aux && aux->asn1_cb)
| 86999-4210617 | ||||||||||||
95 | asn1_cb = aux->asn1_cb; executed 591504 times by 2 tests: asn1_cb = aux->asn1_cb; Executed by:
| 591504 | ||||||||||||
96 | - | |||||||||||||
97 | switch (it->itype) { | - | ||||||||||||
98 | - | |||||||||||||
99 | case ASN1_ITYPE_PRIMITIVE: executed 2978213 times by 2 tests: case 0x0: Executed by:
| 2978213 | ||||||||||||
100 | if (it->templates)
| 233184-2745029 | ||||||||||||
101 | return asn1_template_ex_i2d(pval, out, it->templates, executed 233184 times by 1 test: return asn1_template_ex_i2d(pval, out, it->templates, tag, aclass); Executed by:
| 233184 | ||||||||||||
102 | tag, aclass); executed 233184 times by 1 test: return asn1_template_ex_i2d(pval, out, it->templates, tag, aclass); Executed by:
| 233184 | ||||||||||||
103 | return asn1_i2d_ex_primitive(pval, out, it, tag, aclass); executed 2745029 times by 2 tests: return asn1_i2d_ex_primitive(pval, out, it, tag, aclass); Executed by:
| 2745029 | ||||||||||||
104 | - | |||||||||||||
105 | case ASN1_ITYPE_MSTRING: executed 592012 times by 1 test: case 0x5: Executed by:
| 592012 | ||||||||||||
106 | return asn1_i2d_ex_primitive(pval, out, it, -1, aclass); executed 592012 times by 1 test: return asn1_i2d_ex_primitive(pval, out, it, -1, aclass); Executed by:
| 592012 | ||||||||||||
107 | - | |||||||||||||
108 | case ASN1_ITYPE_CHOICE: executed 77111 times by 1 test: case 0x2: Executed by:
| 77111 | ||||||||||||
109 | if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
| 0-45270 | ||||||||||||
110 | return 0; never executed: return 0; | 0 | ||||||||||||
111 | i = asn1_get_choice_selector(pval, it); | - | ||||||||||||
112 | if ((i >= 0) && (i < it->tcount)) {
| 0-77111 | ||||||||||||
113 | ASN1_VALUE **pchval; | - | ||||||||||||
114 | const ASN1_TEMPLATE *chtt; | - | ||||||||||||
115 | chtt = it->templates + i; | - | ||||||||||||
116 | pchval = asn1_get_field_ptr(pval, chtt); | - | ||||||||||||
117 | return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass); executed 77111 times by 1 test: return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass); Executed by:
| 77111 | ||||||||||||
118 | } | - | ||||||||||||
119 | /* Fixme: error condition if selector out of range */ | - | ||||||||||||
120 | if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
| 0 | ||||||||||||
121 | return 0; never executed: return 0; | 0 | ||||||||||||
122 | break; never executed: break; | 0 | ||||||||||||
123 | - | |||||||||||||
124 | case ASN1_ITYPE_EXTERN: executed 32353 times by 1 test: case 0x4: Executed by:
| 32353 | ||||||||||||
125 | /* If new style i2d it does all the work */ | - | ||||||||||||
126 | ef = it->funcs; | - | ||||||||||||
127 | return ef->asn1_ex_i2d(pval, out, it, tag, aclass); executed 32353 times by 1 test: return ef->asn1_ex_i2d(pval, out, it, tag, aclass); Executed by:
| 32353 | ||||||||||||
128 | - | |||||||||||||
129 | case ASN1_ITYPE_NDEF_SEQUENCE: executed 6848 times by 1 test: case 0x6: Executed by:
| 6848 | ||||||||||||
130 | /* Use indefinite length constructed if requested */ | - | ||||||||||||
131 | if (aclass & ASN1_TFLG_NDEF)
| 972-5876 | ||||||||||||
132 | ndef = 2; executed 972 times by 1 test: ndef = 2; Executed by:
| 972 | ||||||||||||
133 | /* fall through */ | - | ||||||||||||
134 | - | |||||||||||||
135 | case ASN1_ITYPE_SEQUENCE: code before this statement executed 6848 times by 1 test: case 0x1: Executed by:
executed 1202583 times by 2 tests: case 0x1: Executed by:
| 6848-1202583 | ||||||||||||
136 | i = asn1_enc_restore(&seqcontlen, out, pval, it); | - | ||||||||||||
137 | /* An error occurred */ | - | ||||||||||||
138 | if (i < 0)
| 0-1209431 | ||||||||||||
139 | return 0; never executed: return 0; | 0 | ||||||||||||
140 | /* We have a valid cached encoding... */ | - | ||||||||||||
141 | if (i > 0)
| 163825-1045606 | ||||||||||||
142 | return seqcontlen; executed 163825 times by 1 test: return seqcontlen; Executed by:
| 163825 | ||||||||||||
143 | /* Otherwise carry on */ | - | ||||||||||||
144 | seqcontlen = 0; | - | ||||||||||||
145 | /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */ | - | ||||||||||||
146 | if (tag == -1) {
| 33474-1012132 | ||||||||||||
147 | tag = V_ASN1_SEQUENCE; | - | ||||||||||||
148 | /* Retain any other flags in aclass */ | - | ||||||||||||
149 | aclass = (aclass & ~ASN1_TFLG_TAG_CLASS) | - | ||||||||||||
150 | | V_ASN1_UNIVERSAL; | - | ||||||||||||
151 | } executed 1012132 times by 2 tests: end of block Executed by:
| 1012132 | ||||||||||||
152 | if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
| 0-883184 | ||||||||||||
153 | return 0; never executed: return 0; | 0 | ||||||||||||
154 | /* First work out sequence content length */ | - | ||||||||||||
155 | for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
| 1045606-2578593 | ||||||||||||
156 | const ASN1_TEMPLATE *seqtt; | - | ||||||||||||
157 | ASN1_VALUE **pseqval; | - | ||||||||||||
158 | int tmplen; | - | ||||||||||||
159 | seqtt = asn1_do_adb(pval, tt, 1); | - | ||||||||||||
160 | if (!seqtt)
| 0-2578593 | ||||||||||||
161 | return 0; never executed: return 0; | 0 | ||||||||||||
162 | pseqval = asn1_get_field_ptr(pval, seqtt); | - | ||||||||||||
163 | tmplen = asn1_template_ex_i2d(pseqval, NULL, seqtt, -1, aclass); | - | ||||||||||||
164 | if (tmplen == -1 || (tmplen > INT_MAX - seqcontlen))
| 0-2578593 | ||||||||||||
165 | return -1; never executed: return -1; | 0 | ||||||||||||
166 | seqcontlen += tmplen; | - | ||||||||||||
167 | } executed 2578593 times by 2 tests: end of block Executed by:
| 2578593 | ||||||||||||
168 | - | |||||||||||||
169 | seqlen = ASN1_object_size(ndef, seqcontlen, tag); | - | ||||||||||||
170 | if (!out || seqlen == -1)
| 0-700744 | ||||||||||||
171 | return seqlen; executed 700744 times by 1 test: return seqlen; Executed by:
| 700744 | ||||||||||||
172 | /* Output SEQUENCE header */ | - | ||||||||||||
173 | ASN1_put_object(out, ndef, seqcontlen, tag, aclass); | - | ||||||||||||
174 | for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
| 344862-873704 | ||||||||||||
175 | const ASN1_TEMPLATE *seqtt; | - | ||||||||||||
176 | ASN1_VALUE **pseqval; | - | ||||||||||||
177 | seqtt = asn1_do_adb(pval, tt, 1); | - | ||||||||||||
178 | if (!seqtt)
| 0-873704 | ||||||||||||
179 | return 0; never executed: return 0; | 0 | ||||||||||||
180 | pseqval = asn1_get_field_ptr(pval, seqtt); | - | ||||||||||||
181 | /* FIXME: check for errors in enhanced version */ | - | ||||||||||||
182 | asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass); | - | ||||||||||||
183 | } executed 873704 times by 2 tests: end of block Executed by:
| 873704 | ||||||||||||
184 | if (ndef == 2)
| 266-344596 | ||||||||||||
185 | ASN1_put_eoc(out); executed 266 times by 1 test: ASN1_put_eoc(out); Executed by:
| 266 | ||||||||||||
186 | if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
| 0-270437 | ||||||||||||
187 | return 0; never executed: return 0; | 0 | ||||||||||||
188 | return seqlen; executed 344862 times by 2 tests: return seqlen; Executed by:
| 344862 | ||||||||||||
189 | - | |||||||||||||
190 | default: never executed: default: | 0 | ||||||||||||
191 | return 0; never executed: return 0; | 0 | ||||||||||||
192 | - | |||||||||||||
193 | } | - | ||||||||||||
194 | return 0; never executed: return 0; | 0 | ||||||||||||
195 | } | - | ||||||||||||
196 | - | |||||||||||||
197 | static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | - | ||||||||||||
198 | const ASN1_TEMPLATE *tt, int tag, int iclass) | - | ||||||||||||
199 | { | - | ||||||||||||
200 | int i, ret, flags, ttag, tclass, ndef; | - | ||||||||||||
201 | ASN1_VALUE *tval; | - | ||||||||||||
202 | flags = tt->flags; | - | ||||||||||||
203 | - | |||||||||||||
204 | /* | - | ||||||||||||
205 | * If field is embedded then val needs fixing so it is a pointer to | - | ||||||||||||
206 | * a pointer to a field. | - | ||||||||||||
207 | */ | - | ||||||||||||
208 | if (flags & ASN1_TFLG_EMBED) {
| 721182-3041410 | ||||||||||||
209 | tval = (ASN1_VALUE *)pval; | - | ||||||||||||
210 | pval = &tval; | - | ||||||||||||
211 | } executed 721182 times by 1 test: end of block Executed by:
| 721182 | ||||||||||||
212 | /* | - | ||||||||||||
213 | * Work out tag and class to use: tagging may come either from the | - | ||||||||||||
214 | * template or the arguments, not both because this would create | - | ||||||||||||
215 | * ambiguity. Additionally the iclass argument may contain some | - | ||||||||||||
216 | * additional flags which should be noted and passed down to other | - | ||||||||||||
217 | * levels. | - | ||||||||||||
218 | */ | - | ||||||||||||
219 | if (flags & ASN1_TFLG_TAG_MASK) {
| 367177-3395415 | ||||||||||||
220 | /* Error if argument and template tagging */ | - | ||||||||||||
221 | if (tag != -1)
| 0-367177 | ||||||||||||
222 | /* FIXME: error code here */ | - | ||||||||||||
223 | return -1; never executed: return -1; | 0 | ||||||||||||
224 | /* Get tagging from template */ | - | ||||||||||||
225 | ttag = tt->tag; | - | ||||||||||||
226 | tclass = flags & ASN1_TFLG_TAG_CLASS; | - | ||||||||||||
227 | } else if (tag != -1) { executed 367177 times by 1 test: end of block Executed by:
| 0-3395415 | ||||||||||||
228 | /* No template tagging, get from arguments */ | - | ||||||||||||
229 | ttag = tag; | - | ||||||||||||
230 | tclass = iclass & ASN1_TFLG_TAG_CLASS; | - | ||||||||||||
231 | } else { never executed: end of block | 0 | ||||||||||||
232 | ttag = -1; | - | ||||||||||||
233 | tclass = 0; | - | ||||||||||||
234 | } executed 3395415 times by 2 tests: end of block Executed by:
| 3395415 | ||||||||||||
235 | /* | - | ||||||||||||
236 | * Remove any class mask from iflag. | - | ||||||||||||
237 | */ | - | ||||||||||||
238 | iclass &= ~ASN1_TFLG_TAG_CLASS; | - | ||||||||||||
239 | - | |||||||||||||
240 | /* | - | ||||||||||||
241 | * At this point 'ttag' contains the outer tag to use, 'tclass' is the | - | ||||||||||||
242 | * class and iclass is any flags passed to this function. | - | ||||||||||||
243 | */ | - | ||||||||||||
244 | - | |||||||||||||
245 | /* if template and arguments require ndef, use it */ | - | ||||||||||||
246 | if ((flags & ASN1_TFLG_NDEF) && (iclass & ASN1_TFLG_NDEF))
| 474-3759696 | ||||||||||||
247 | ndef = 2; executed 474 times by 1 test: ndef = 2; Executed by:
| 474 | ||||||||||||
248 | else | - | ||||||||||||
249 | ndef = 1; executed 3762118 times by 2 tests: ndef = 1; Executed by:
| 3762118 | ||||||||||||
250 | - | |||||||||||||
251 | if (flags & ASN1_TFLG_SK_MASK) {
| 298804-3463788 | ||||||||||||
252 | /* SET OF, SEQUENCE OF */ | - | ||||||||||||
253 | STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval; | - | ||||||||||||
254 | int isset, sktag, skaclass; | - | ||||||||||||
255 | int skcontlen, sklen; | - | ||||||||||||
256 | ASN1_VALUE *skitem; | - | ||||||||||||
257 | - | |||||||||||||
258 | if (!*pval)
| 23239-275565 | ||||||||||||
259 | return 0; executed 23239 times by 1 test: return 0; Executed by:
| 23239 | ||||||||||||
260 | - | |||||||||||||
261 | if (flags & ASN1_TFLG_SET_OF) {
| 31044-244521 | ||||||||||||
262 | isset = 1; | - | ||||||||||||
263 | /* 2 means we reorder */ | - | ||||||||||||
264 | if (flags & ASN1_TFLG_SEQUENCE_OF)
| 210-244311 | ||||||||||||
265 | isset = 2; executed 210 times by 1 test: isset = 2; Executed by:
| 210 | ||||||||||||
266 | } else executed 244521 times by 1 test: end of block Executed by:
| 244521 | ||||||||||||
267 | isset = 0; executed 31044 times by 1 test: isset = 0; Executed by:
| 31044 | ||||||||||||
268 | - | |||||||||||||
269 | /* | - | ||||||||||||
270 | * Work out inner tag value: if EXPLICIT or no tagging use underlying | - | ||||||||||||
271 | * type. | - | ||||||||||||
272 | */ | - | ||||||||||||
273 | if ((ttag != -1) && !(flags & ASN1_TFLG_EXPTAG)) {
| 116-266338 | ||||||||||||
274 | sktag = ttag; | - | ||||||||||||
275 | skaclass = tclass; | - | ||||||||||||
276 | } else { executed 9111 times by 1 test: end of block Executed by:
| 9111 | ||||||||||||
277 | skaclass = V_ASN1_UNIVERSAL; | - | ||||||||||||
278 | if (isset)
| 27024-239430 | ||||||||||||
279 | sktag = V_ASN1_SET; executed 239430 times by 1 test: sktag = 17; Executed by:
| 239430 | ||||||||||||
280 | else | - | ||||||||||||
281 | sktag = V_ASN1_SEQUENCE; executed 27024 times by 1 test: sktag = 16; Executed by:
| 27024 | ||||||||||||
282 | } | - | ||||||||||||
283 | - | |||||||||||||
284 | /* Determine total length of items */ | - | ||||||||||||
285 | skcontlen = 0; | - | ||||||||||||
286 | for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
| 275565-780284 | ||||||||||||
287 | int tmplen; | - | ||||||||||||
288 | skitem = sk_ASN1_VALUE_value(sk, i); | - | ||||||||||||
289 | tmplen = ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item), | - | ||||||||||||
290 | -1, iclass); | - | ||||||||||||
291 | if (tmplen == -1 || (skcontlen > INT_MAX - tmplen))
| 0-780284 | ||||||||||||
292 | return -1; never executed: return -1; | 0 | ||||||||||||
293 | skcontlen += tmplen; | - | ||||||||||||
294 | } executed 780284 times by 1 test: end of block Executed by:
| 780284 | ||||||||||||
295 | sklen = ASN1_object_size(ndef, skcontlen, sktag); | - | ||||||||||||
296 | if (sklen == -1)
| 0-275565 | ||||||||||||
297 | return -1; never executed: return -1; | 0 | ||||||||||||
298 | /* If EXPLICIT need length of surrounding tag */ | - | ||||||||||||
299 | if (flags & ASN1_TFLG_EXPTAG)
| 116-275449 | ||||||||||||
300 | ret = ASN1_object_size(ndef, sklen, ttag); executed 116 times by 1 test: ret = ASN1_object_size(ndef, sklen, ttag); Executed by:
| 116 | ||||||||||||
301 | else | - | ||||||||||||
302 | ret = sklen; executed 275449 times by 1 test: ret = sklen; Executed by:
| 275449 | ||||||||||||
303 | - | |||||||||||||
304 | if (!out || ret == -1)
| 0-162969 | ||||||||||||
305 | return ret; executed 162969 times by 1 test: return ret; Executed by:
| 162969 | ||||||||||||
306 | - | |||||||||||||
307 | /* Now encode this lot... */ | - | ||||||||||||
308 | /* EXPLICIT tag */ | - | ||||||||||||
309 | if (flags & ASN1_TFLG_EXPTAG)
| 35-112561 | ||||||||||||
310 | ASN1_put_object(out, ndef, sklen, ttag, tclass); executed 35 times by 1 test: ASN1_put_object(out, ndef, sklen, ttag, tclass); Executed by:
| 35 | ||||||||||||
311 | /* SET or SEQUENCE and IMPLICIT tag */ | - | ||||||||||||
312 | ASN1_put_object(out, ndef, skcontlen, sktag, skaclass); | - | ||||||||||||
313 | /* And the stuff itself */ | - | ||||||||||||
314 | asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item), | - | ||||||||||||
315 | isset, iclass); | - | ||||||||||||
316 | if (ndef == 2) {
| 0-112596 | ||||||||||||
317 | ASN1_put_eoc(out); | - | ||||||||||||
318 | if (flags & ASN1_TFLG_EXPTAG)
| 0 | ||||||||||||
319 | ASN1_put_eoc(out); never executed: ASN1_put_eoc(out); | 0 | ||||||||||||
320 | } never executed: end of block | 0 | ||||||||||||
321 | - | |||||||||||||
322 | return ret; executed 112596 times by 1 test: return ret; Executed by:
| 112596 | ||||||||||||
323 | } | - | ||||||||||||
324 | - | |||||||||||||
325 | if (flags & ASN1_TFLG_EXPTAG) {
| 234511-3229277 | ||||||||||||
326 | /* EXPLICIT tagging */ | - | ||||||||||||
327 | /* Find length of tagged item */ | - | ||||||||||||
328 | i = ASN1_item_ex_i2d(pval, NULL, ASN1_ITEM_ptr(tt->item), -1, iclass); | - | ||||||||||||
329 | if (!i)
| 66575-167936 | ||||||||||||
330 | return 0; executed 167936 times by 1 test: return 0; Executed by:
| 167936 | ||||||||||||
331 | /* Find length of EXPLICIT tag */ | - | ||||||||||||
332 | ret = ASN1_object_size(ndef, i, ttag); | - | ||||||||||||
333 | if (out && ret != -1) {
| 0-46990 | ||||||||||||
334 | /* Output tag and item */ | - | ||||||||||||
335 | ASN1_put_object(out, ndef, i, ttag, tclass); | - | ||||||||||||
336 | ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1, iclass); | - | ||||||||||||
337 | if (ndef == 2)
| 124-19461 | ||||||||||||
338 | ASN1_put_eoc(out); executed 124 times by 1 test: ASN1_put_eoc(out); Executed by:
| 124 | ||||||||||||
339 | } executed 19585 times by 1 test: end of block Executed by:
| 19585 | ||||||||||||
340 | return ret; executed 66575 times by 1 test: return ret; Executed by:
| 66575 | ||||||||||||
341 | } | - | ||||||||||||
342 | - | |||||||||||||
343 | /* Either normal or IMPLICIT tagging: combine class and flags */ | - | ||||||||||||
344 | return ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), executed 3229277 times by 2 tests: return ASN1_item_ex_i2d(pval, out, (tt->item), ttag, tclass | iclass); Executed by:
| 3229277 | ||||||||||||
345 | ttag, tclass | iclass); executed 3229277 times by 2 tests: return ASN1_item_ex_i2d(pval, out, (tt->item), ttag, tclass | iclass); Executed by:
| 3229277 | ||||||||||||
346 | - | |||||||||||||
347 | } | - | ||||||||||||
348 | - | |||||||||||||
349 | /* Temporary structure used to hold DER encoding of items for SET OF */ | - | ||||||||||||
350 | - | |||||||||||||
351 | typedef struct { | - | ||||||||||||
352 | unsigned char *data; | - | ||||||||||||
353 | int length; | - | ||||||||||||
354 | ASN1_VALUE *field; | - | ||||||||||||
355 | } DER_ENC; | - | ||||||||||||
356 | - | |||||||||||||
357 | static int der_cmp(const void *a, const void *b) | - | ||||||||||||
358 | { | - | ||||||||||||
359 | const DER_ENC *d1 = a, *d2 = b; | - | ||||||||||||
360 | int cmplen, i; | - | ||||||||||||
361 | cmplen = (d1->length < d2->length) ? d1->length : d2->length;
| 18274-340247 | ||||||||||||
362 | i = memcmp(d1->data, d2->data, cmplen); | - | ||||||||||||
363 | if (i)
| 179115-179406 | ||||||||||||
364 | return i; executed 179406 times by 1 test: return i; Executed by:
| 179406 | ||||||||||||
365 | return d1->length - d2->length; executed 179115 times by 1 test: return d1->length - d2->length; Executed by:
| 179115 | ||||||||||||
366 | } | - | ||||||||||||
367 | - | |||||||||||||
368 | /* Output the content octets of SET OF or SEQUENCE OF */ | - | ||||||||||||
369 | - | |||||||||||||
370 | static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, | - | ||||||||||||
371 | int skcontlen, const ASN1_ITEM *item, | - | ||||||||||||
372 | int do_sort, int iclass) | - | ||||||||||||
373 | { | - | ||||||||||||
374 | int i; | - | ||||||||||||
375 | ASN1_VALUE *skitem; | - | ||||||||||||
376 | unsigned char *tmpdat = NULL, *p = NULL; | - | ||||||||||||
377 | DER_ENC *derlst = NULL, *tder; | - | ||||||||||||
378 | if (do_sort) {
| 10188-102408 | ||||||||||||
379 | /* Don't need to sort less than 2 items */ | - | ||||||||||||
380 | if (sk_ASN1_VALUE_num(sk) < 2)
| 4402-98006 | ||||||||||||
381 | do_sort = 0; executed 98006 times by 1 test: do_sort = 0; Executed by:
| 98006 | ||||||||||||
382 | else { | - | ||||||||||||
383 | derlst = OPENSSL_malloc(sk_ASN1_VALUE_num(sk) | - | ||||||||||||
384 | * sizeof(*derlst)); | - | ||||||||||||
385 | if (derlst == NULL)
| 0-4402 | ||||||||||||
386 | return 0; never executed: return 0; | 0 | ||||||||||||
387 | tmpdat = OPENSSL_malloc(skcontlen); | - | ||||||||||||
388 | if (tmpdat == NULL) {
| 0-4402 | ||||||||||||
389 | OPENSSL_free(derlst); | - | ||||||||||||
390 | return 0; never executed: return 0; | 0 | ||||||||||||
391 | } | - | ||||||||||||
392 | } executed 4402 times by 1 test: end of block Executed by:
| 4402 | ||||||||||||
393 | } | - | ||||||||||||
394 | /* If not sorting just output each item */ | - | ||||||||||||
395 | if (!do_sort) {
| 4402-108194 | ||||||||||||
396 | for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
| 108194-173283 | ||||||||||||
397 | skitem = sk_ASN1_VALUE_value(sk, i); | - | ||||||||||||
398 | ASN1_item_ex_i2d(&skitem, out, item, -1, iclass); | - | ||||||||||||
399 | } executed 173283 times by 1 test: end of block Executed by:
| 173283 | ||||||||||||
400 | return 1; executed 108194 times by 1 test: return 1; Executed by:
| 108194 | ||||||||||||
401 | } | - | ||||||||||||
402 | p = tmpdat; | - | ||||||||||||
403 | - | |||||||||||||
404 | /* Doing sort: build up a list of each member's DER encoding */ | - | ||||||||||||
405 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
| 4402-80947 | ||||||||||||
406 | skitem = sk_ASN1_VALUE_value(sk, i); | - | ||||||||||||
407 | tder->data = p; | - | ||||||||||||
408 | tder->length = ASN1_item_ex_i2d(&skitem, &p, item, -1, iclass); | - | ||||||||||||
409 | tder->field = skitem; | - | ||||||||||||
410 | } executed 80947 times by 1 test: end of block Executed by:
| 80947 | ||||||||||||
411 | - | |||||||||||||
412 | /* Now sort them */ | - | ||||||||||||
413 | qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp); | - | ||||||||||||
414 | /* Output sorted DER encoding */ | - | ||||||||||||
415 | p = *out; | - | ||||||||||||
416 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
| 4402-80947 | ||||||||||||
417 | memcpy(p, tder->data, tder->length); | - | ||||||||||||
418 | p += tder->length; | - | ||||||||||||
419 | } executed 80947 times by 1 test: end of block Executed by:
| 80947 | ||||||||||||
420 | *out = p; | - | ||||||||||||
421 | /* If do_sort is 2 then reorder the STACK */ | - | ||||||||||||
422 | if (do_sort == 2) {
| 83-4319 | ||||||||||||
423 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)
| 83-783 | ||||||||||||
424 | (void)sk_ASN1_VALUE_set(sk, i, tder->field); executed 783 times by 1 test: (void)sk_ASN1_VALUE_set(sk, i, tder->field); Executed by:
| 783 | ||||||||||||
425 | } executed 83 times by 1 test: end of block Executed by:
| 83 | ||||||||||||
426 | OPENSSL_free(derlst); | - | ||||||||||||
427 | OPENSSL_free(tmpdat); | - | ||||||||||||
428 | return 1; executed 4402 times by 1 test: return 1; Executed by:
| 4402 | ||||||||||||
429 | } | - | ||||||||||||
430 | - | |||||||||||||
431 | static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, | - | ||||||||||||
432 | const ASN1_ITEM *it, int tag, int aclass) | - | ||||||||||||
433 | { | - | ||||||||||||
434 | int len; | - | ||||||||||||
435 | int utype; | - | ||||||||||||
436 | int usetag; | - | ||||||||||||
437 | int ndef = 0; | - | ||||||||||||
438 | - | |||||||||||||
439 | utype = it->utype; | - | ||||||||||||
440 | - | |||||||||||||
441 | /* | - | ||||||||||||
442 | * Get length of content octets and maybe find out the underlying type. | - | ||||||||||||
443 | */ | - | ||||||||||||
444 | - | |||||||||||||
445 | len = asn1_ex_i2c(pval, NULL, &utype, it); | - | ||||||||||||
446 | - | |||||||||||||
447 | /* | - | ||||||||||||
448 | * If SEQUENCE, SET or OTHER then header is included in pseudo content | - | ||||||||||||
449 | * octets so don't include tag+length. We need to check here because the | - | ||||||||||||
450 | * call to asn1_ex_i2c() could change utype. | - | ||||||||||||
451 | */ | - | ||||||||||||
452 | if ((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) ||
| 8940-3270707 | ||||||||||||
453 | (utype == V_ASN1_OTHER))
| 59936-3201831 | ||||||||||||
454 | usetag = 0; executed 135210 times by 1 test: usetag = 0; Executed by:
| 135210 | ||||||||||||
455 | else | - | ||||||||||||
456 | usetag = 1; executed 3201831 times by 2 tests: usetag = 1; Executed by:
| 3201831 | ||||||||||||
457 | - | |||||||||||||
458 | /* -1 means omit type */ | - | ||||||||||||
459 | - | |||||||||||||
460 | if (len == -1)
| 388204-2948837 | ||||||||||||
461 | return 0; executed 388204 times by 1 test: return 0; Executed by:
| 388204 | ||||||||||||
462 | - | |||||||||||||
463 | /* -2 return is special meaning use ndef */ | - | ||||||||||||
464 | if (len == -2) {
| 570-2948267 | ||||||||||||
465 | ndef = 2; | - | ||||||||||||
466 | len = 0; | - | ||||||||||||
467 | } executed 570 times by 1 test: end of block Executed by:
| 570 | ||||||||||||
468 | - | |||||||||||||
469 | /* If not implicitly tagged get tag from underlying type */ | - | ||||||||||||
470 | if (tag == -1)
| 27694-2921143 | ||||||||||||
471 | tag = utype; executed 2921143 times by 2 tests: tag = utype; Executed by:
| 2921143 | ||||||||||||
472 | - | |||||||||||||
473 | /* Output tag+length followed by content octets */ | - | ||||||||||||
474 | if (out) {
| 694848-2253989 | ||||||||||||
475 | if (usetag)
| 33749-661099 | ||||||||||||
476 | ASN1_put_object(out, ndef, len, tag, aclass); executed 661099 times by 2 tests: ASN1_put_object(out, ndef, len, tag, aclass); Executed by:
| 661099 | ||||||||||||
477 | asn1_ex_i2c(pval, *out, &utype, it); | - | ||||||||||||
478 | if (ndef)
| 90-694758 | ||||||||||||
479 | ASN1_put_eoc(out); executed 90 times by 1 test: ASN1_put_eoc(out); Executed by:
| 90 | ||||||||||||
480 | else | - | ||||||||||||
481 | *out += len; executed 694758 times by 2 tests: *out += len; Executed by:
| 694758 | ||||||||||||
482 | } | - | ||||||||||||
483 | - | |||||||||||||
484 | if (usetag)
| 135210-2813627 | ||||||||||||
485 | return ASN1_object_size(ndef, len, tag); executed 2813627 times by 2 tests: return ASN1_object_size(ndef, len, tag); Executed by:
| 2813627 | ||||||||||||
486 | return len; executed 135210 times by 1 test: return len; Executed by:
| 135210 | ||||||||||||
487 | } | - | ||||||||||||
488 | - | |||||||||||||
489 | /* Produce content octets from a structure */ | - | ||||||||||||
490 | - | |||||||||||||
491 | static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, | - | ||||||||||||
492 | const ASN1_ITEM *it) | - | ||||||||||||
493 | { | - | ||||||||||||
494 | ASN1_BOOLEAN *tbool = NULL; | - | ||||||||||||
495 | ASN1_STRING *strtmp; | - | ||||||||||||
496 | ASN1_OBJECT *otmp; | - | ||||||||||||
497 | int utype; | - | ||||||||||||
498 | const unsigned char *cont; | - | ||||||||||||
499 | unsigned char c; | - | ||||||||||||
500 | int len; | - | ||||||||||||
501 | const ASN1_PRIMITIVE_FUNCS *pf; | - | ||||||||||||
502 | pf = it->funcs; | - | ||||||||||||
503 | if (pf && pf->prim_i2c)
| 0-3690084 | ||||||||||||
504 | return pf->prim_i2c(pval, cout, putype, it); executed 341805 times by 2 tests: return pf->prim_i2c(pval, cout, putype, it); Executed by:
| 341805 | ||||||||||||
505 | - | |||||||||||||
506 | /* Should type be omitted? */ | - | ||||||||||||
507 | if ((it->itype != ASN1_ITYPE_PRIMITIVE)
| 739541-2950543 | ||||||||||||
508 | || (it->utype != V_ASN1_BOOLEAN)) {
| 91366-2859177 | ||||||||||||
509 | if (!*pval)
| 248951-3349767 | ||||||||||||
510 | return -1; executed 248951 times by 1 test: return -1; Executed by:
| 248951 | ||||||||||||
511 | } executed 3349767 times by 2 tests: end of block Executed by:
| 3349767 | ||||||||||||
512 | - | |||||||||||||
513 | if (it->itype == ASN1_ITYPE_MSTRING) {
| 739541-2701592 | ||||||||||||
514 | /* If MSTRING type set the underlying type */ | - | ||||||||||||
515 | strtmp = (ASN1_STRING *)*pval; | - | ||||||||||||
516 | utype = strtmp->type; | - | ||||||||||||
517 | *putype = utype; | - | ||||||||||||
518 | } else if (it->utype == V_ASN1_ANY) { executed 739541 times by 1 test: end of block Executed by:
| 714522-1987070 | ||||||||||||
519 | /* If ANY set type and pointer to value */ | - | ||||||||||||
520 | ASN1_TYPE *typ; | - | ||||||||||||
521 | typ = (ASN1_TYPE *)*pval; | - | ||||||||||||
522 | utype = typ->type; | - | ||||||||||||
523 | *putype = utype; | - | ||||||||||||
524 | pval = &typ->value.asn1_value; | - | ||||||||||||
525 | } else executed 714522 times by 1 test: end of block Executed by:
| 714522 | ||||||||||||
526 | utype = *putype; executed 1987070 times by 2 tests: utype = *putype; Executed by:
| 1987070 | ||||||||||||
527 | - | |||||||||||||
528 | switch (utype) { | - | ||||||||||||
529 | case V_ASN1_OBJECT: executed 1389267 times by 1 test: case 6: Executed by:
| 1389267 | ||||||||||||
530 | otmp = (ASN1_OBJECT *)*pval; | - | ||||||||||||
531 | cont = otmp->data; | - | ||||||||||||
532 | len = otmp->length; | - | ||||||||||||
533 | if (cont == NULL || len == 0)
| 0-1389267 | ||||||||||||
534 | return -1; never executed: return -1; | 0 | ||||||||||||
535 | break; executed 1389267 times by 1 test: break; Executed by:
| 1389267 | ||||||||||||
536 | - | |||||||||||||
537 | case V_ASN1_NULL: executed 181560 times by 1 test: case 5: Executed by:
| 181560 | ||||||||||||
538 | cont = NULL; | - | ||||||||||||
539 | len = 0; | - | ||||||||||||
540 | break; executed 181560 times by 1 test: break; Executed by:
| 181560 | ||||||||||||
541 | - | |||||||||||||
542 | case V_ASN1_BOOLEAN: executed 96883 times by 1 test: case 1: Executed by:
| 96883 | ||||||||||||
543 | tbool = (ASN1_BOOLEAN *)pval; | - | ||||||||||||
544 | if (*tbool == -1)
| 14420-82463 | ||||||||||||
545 | return -1; executed 82463 times by 1 test: return -1; Executed by:
| 82463 | ||||||||||||
546 | if (it->utype != V_ASN1_ANY) {
| 5517-8903 | ||||||||||||
547 | /* | - | ||||||||||||
548 | * Default handling if value == size field then omit | - | ||||||||||||
549 | */ | - | ||||||||||||
550 | if (*tbool && (it->size > 0))
| 1-4555 | ||||||||||||
551 | return -1; executed 1 time by 1 test: return -1; Executed by:
| 1 | ||||||||||||
552 | if (!*tbool && !it->size)
| 1839-4554 | ||||||||||||
553 | return -1; executed 1839 times by 1 test: return -1; Executed by:
| 1839 | ||||||||||||
554 | } executed 7063 times by 1 test: end of block Executed by:
| 7063 | ||||||||||||
555 | c = (unsigned char)*tbool; | - | ||||||||||||
556 | cont = &c; | - | ||||||||||||
557 | len = 1; | - | ||||||||||||
558 | break; executed 12580 times by 1 test: break; Executed by:
| 12580 | ||||||||||||
559 | - | |||||||||||||
560 | case V_ASN1_BIT_STRING: executed 309577 times by 1 test: case 3: Executed by:
| 309577 | ||||||||||||
561 | return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, executed 309577 times by 1 test: return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, cout ? &cout : ((void *)0) ); Executed by:
| 309577 | ||||||||||||
562 | cout ? &cout : NULL); executed 309577 times by 1 test: return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, cout ? &cout : ((void *)0) ); Executed by:
| 309577 | ||||||||||||
563 | - | |||||||||||||
564 | case V_ASN1_INTEGER: executed 116344 times by 1 test: case 2: Executed by:
| 116344 | ||||||||||||
565 | case V_ASN1_ENUMERATED: executed 10863 times by 1 test: case 10: Executed by:
| 10863 | ||||||||||||
566 | /* | - | ||||||||||||
567 | * These are all have the same content format as ASN1_INTEGER | - | ||||||||||||
568 | */ | - | ||||||||||||
569 | return i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : NULL); executed 127207 times by 1 test: return i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : ((void *)0) ); Executed by:
| 127207 | ||||||||||||
570 | - | |||||||||||||
571 | case V_ASN1_OCTET_STRING: executed 240812 times by 2 tests: case 4: Executed by:
| 240812 | ||||||||||||
572 | case V_ASN1_NUMERICSTRING: executed 41879 times by 1 test: case 18: Executed by:
| 41879 | ||||||||||||
573 | case V_ASN1_PRINTABLESTRING: executed 11684 times by 1 test: case 19: Executed by:
| 11684 | ||||||||||||
574 | case V_ASN1_T61STRING: executed 76427 times by 1 test: case 20: Executed by:
| 76427 | ||||||||||||
575 | case V_ASN1_VIDEOTEXSTRING: executed 460 times by 1 test: case 21: Executed by:
| 460 | ||||||||||||
576 | case V_ASN1_IA5STRING: executed 11918 times by 1 test: case 22: Executed by:
| 11918 | ||||||||||||
577 | case V_ASN1_UTCTIME: executed 4171 times by 1 test: case 23: Executed by:
| 4171 | ||||||||||||
578 | case V_ASN1_GENERALIZEDTIME: executed 11892 times by 1 test: case 24: Executed by:
| 11892 | ||||||||||||
579 | case V_ASN1_GRAPHICSTRING: executed 6952 times by 1 test: case 25: Executed by:
| 6952 | ||||||||||||
580 | case V_ASN1_VISIBLESTRING: executed 8334 times by 1 test: case 26: Executed by:
| 8334 | ||||||||||||
581 | case V_ASN1_GENERALSTRING: executed 7780 times by 1 test: case 27: Executed by:
| 7780 | ||||||||||||
582 | case V_ASN1_UNIVERSALSTRING: executed 51715 times by 1 test: case 28: Executed by:
| 51715 | ||||||||||||
583 | case V_ASN1_BMPSTRING: executed 31457 times by 1 test: case 30: Executed by:
| 31457 | ||||||||||||
584 | case V_ASN1_UTF8STRING: executed 530827 times by 1 test: case 12: Executed by:
| 530827 | ||||||||||||
585 | case V_ASN1_SEQUENCE: executed 85325 times by 1 test: case 16: Executed by:
| 85325 | ||||||||||||
586 | case V_ASN1_SET: executed 10772 times by 1 test: case 17: Executed by:
| 10772 | ||||||||||||
587 | default: executed 204234 times by 1 test: default: Executed by:
| 204234 | ||||||||||||
588 | /* All based on ASN1_STRING and handled the same */ | - | ||||||||||||
589 | strtmp = (ASN1_STRING *)*pval; | - | ||||||||||||
590 | /* Special handling for NDEF */ | - | ||||||||||||
591 | if ((it->size == ASN1_TFLG_NDEF)
| 852-1335787 | ||||||||||||
592 | && (strtmp->flags & ASN1_STRING_FLAG_NDEF)) {
| 192-660 | ||||||||||||
593 | if (cout) {
| 90-570 | ||||||||||||
594 | strtmp->data = cout; | - | ||||||||||||
595 | strtmp->length = 0; | - | ||||||||||||
596 | } executed 90 times by 1 test: end of block Executed by:
| 90 | ||||||||||||
597 | /* Special return code */ | - | ||||||||||||
598 | return -2; executed 660 times by 1 test: return -2; Executed by:
| 660 | ||||||||||||
599 | } | - | ||||||||||||
600 | cont = strtmp->data; | - | ||||||||||||
601 | len = strtmp->length; | - | ||||||||||||
602 | - | |||||||||||||
603 | break; executed 1335979 times by 2 tests: break; Executed by:
| 1335979 | ||||||||||||
604 | - | |||||||||||||
605 | } | - | ||||||||||||
606 | if (cout && len)
| 103868-2370881 | ||||||||||||
607 | memcpy(cout, cont, len); executed 444637 times by 2 tests: memcpy(cout, cont, len); Executed by:
| 444637 | ||||||||||||
608 | return len; executed 2919386 times by 2 tests: return len; Executed by:
| 2919386 | ||||||||||||
609 | } | - | ||||||||||||
Source code | Switch to Preprocessed file |