OpenCoverage

x_long.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/x_long.c
Switch to Source codePreprocessed file
LineSourceCount
1static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it);-
2static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it);-
3-
4static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,-
5 const ASN1_ITEM *it);-
6static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,-
7 int utype, char *free_cont, const ASN1_ITEM *it);-
8static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,-
9 int indent, const ASN1_PCTX *pctx);-
10-
11static ASN1_PRIMITIVE_FUNCS long_pf = {-
12 -
13 ((void *)0)-
14 , 0,-
15 long_new,-
16 long_free,-
17 long_free,-
18 long_c2i,-
19 long_i2c,-
20 long_print-
21};-
22-
23const ASN1_ITEM LONG_it = {-
24 0x0, 2, -
25 ((void *)0)-
26 , 0, &long_pf, 0x7fffffffL, "LONG"-
27};-
28-
29const ASN1_ITEM ZLONG_it = {-
30 0x0, 2, -
31 ((void *)0)-
32 , 0, &long_pf, 0, "ZLONG"-
33};-
34-
35static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it)-
36{-
37 memcpy(pval, &it->size, (sizeof(*pval) < sizeof(it->size) ? sizeof(*pval) : sizeof(it->size)));-
38 return
executed 46 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 46 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
46
39}-
40-
41static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it)-
42{-
43 memcpy(pval, &it->size, (sizeof(*pval) < sizeof(it->size) ? sizeof(*pval) : sizeof(it->size)));-
44}
executed 6784 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6784
45-
46-
47-
48-
49-
50-
51-
52static int num_bits_ulong(unsigned long value)-
53{-
54 size_t i;-
55 unsigned long ret = 0;-
56-
57-
58-
59-
60-
61-
62-
63 for (i = 0; i < sizeof(value) * 8
i < sizeof(value) * 8Description
TRUEevaluated 25472 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 398 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++) {
398-25472
64 ret += (value != 0);-
65 value >>= 1;-
66 }
executed 25472 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
25472
67-
68 return
executed 398 times by 1 test: return (int)ret;
Executed by:
  • libcrypto.so.1.1
(int)ret;
executed 398 times by 1 test: return (int)ret;
Executed by:
  • libcrypto.so.1.1
398
69}-
70-
71static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,-
72 const ASN1_ITEM *it)-
73{-
74 long ltmp;-
75 unsigned long utmp, sign;-
76 int clen, pad, i;-
77-
78 memcpy(&ltmp, pval, (sizeof(*pval) < sizeof(ltmp) ? sizeof(*pval) : sizeof(ltmp)));-
79 if (ltmp == it->size
ltmp == it->sizeDescription
TRUEevaluated 48 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 398 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
48-398
80 return
executed 48 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
-1;
executed 48 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
48
81-
82-
83-
84-
85-
86 if (ltmp < 0
ltmp < 0Description
TRUEevaluated 90 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 308 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
90-308
87 sign = 0xff;-
88 utmp = 0 - (unsigned long)ltmp - 1;-
89 }
executed 90 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
90
90 sign = 0;-
91 utmp = ltmp;-
92 }
executed 308 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
308
93 clen = num_bits_ulong(utmp);-
94-
95 if (!(clen & 0x7)
!(clen & 0x7)Description
TRUEevaluated 118 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 280 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
118-280
96 pad = 1;
executed 118 times by 1 test: pad = 1;
Executed by:
  • libcrypto.so.1.1
118
97 else-
98 pad = 0;
executed 280 times by 1 test: pad = 0;
Executed by:
  • libcrypto.so.1.1
280
99-
100-
101 clen = (clen + 7) >> 3;-
102-
103 if (cont !=
cont != ((void *)0)Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 301 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
97-301
104 ((void *)0)
cont != ((void *)0)Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 301 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
97-301
105 ) {-
106 if (pad
padDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 67 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
30-67
107 *
executed 30 times by 1 test: *cont++ = (unsigned char)sign;
Executed by:
  • libcrypto.so.1.1
cont++ = (unsigned char)sign;
executed 30 times by 1 test: *cont++ = (unsigned char)sign;
Executed by:
  • libcrypto.so.1.1
30
108 for (i = clen - 1; i >= 0
i >= 0Description
TRUEevaluated 220 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 97 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i--) {
97-220
109 cont[i] = (unsigned char)(utmp ^ sign);-
110 utmp >>= 8;-
111 }
executed 220 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
220
112 }
executed 97 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
97
113 return
executed 398 times by 1 test: return clen + pad;
Executed by:
  • libcrypto.so.1.1
clen + pad;
executed 398 times by 1 test: return clen + pad;
Executed by:
  • libcrypto.so.1.1
398
114}-
115-
116static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,-
117 int utype, char *free_cont, const ASN1_ITEM *it)-
118{-
119 int i;-
120 long ltmp;-
121 unsigned long utmp = 0, sign = 0x100;-
122-
123 if (len > 1
len > 1Description
TRUEevaluated 77 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 57 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
57-77
124-
125-
126-
127-
128-
129 switch (cont[0]) {-
130 case
executed 18 times by 1 test: case 0xff:
Executed by:
  • libcrypto.so.1.1
0xff:
executed 18 times by 1 test: case 0xff:
Executed by:
  • libcrypto.so.1.1
18
131 cont++;-
132 len--;-
133 sign = 0xff;-
134 break;
executed 18 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
18
135 case
executed 16 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
0:
executed 16 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
16
136 cont++;-
137 len--;-
138 sign = 0;-
139 break;
executed 16 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
16
140 }-
141 }
executed 77 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
77
142 if (len > (int)sizeof(long)
len > (int)sizeof(long)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
24-110
143 ERR_put_error(13,(166),(128),__FILE__,159);-
144 return
executed 24 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 24 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
24
145 }-
146-
147 if (sign == 0x100
sign == 0x100Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
22-88
148-
149 if (len
lenDescription
TRUEevaluated 85 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& (
(cont[0] & 0x80)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 65 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
cont[0] & 0x80)
(cont[0] & 0x80)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 65 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
3-85
150 sign = 0xff;
executed 20 times by 1 test: sign = 0xff;
Executed by:
  • libcrypto.so.1.1
20
151 else-
152 sign = 0;
executed 68 times by 1 test: sign = 0;
Executed by:
  • libcrypto.so.1.1
68
153 } else if (((
((sign ^ cont[0]) & 0x80) == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sign ^ cont[0]) & 0x80) == 0
((sign ^ cont[0]) & 0x80) == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
10-12
154 ERR_put_error(13,(166),(221),__FILE__,170);-
155 return
executed 10 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 10 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
10
156 }-
157 utmp = 0;-
158 for (i = 0; i < len
i < lenDescription
TRUEevaluated 276 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 100 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++) {
100-276
159 utmp <<= 8;-
160 utmp |= cont[i] ^ sign;-
161 }
executed 276 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
276
162 ltmp = (long)utmp;-
163 if (ltmp < 0
ltmp < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 96 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
4-96
164 ERR_put_error(13,(166),(128),__FILE__,180);-
165 return
executed 4 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 4 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
4
166 }-
167 if (sign
signDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 72 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
24-72
168 ltmp = -ltmp - 1;
executed 24 times by 1 test: ltmp = -ltmp - 1;
Executed by:
  • libcrypto.so.1.1
24
169 if (ltmp == it->size
ltmp == it->sizeDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 91 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
5-91
170 ERR_put_error(13,(166),(128),__FILE__,186);-
171 return
executed 5 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 5 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
5
172 }-
173 memcpy(pval, &ltmp, (sizeof(*pval) < sizeof(ltmp) ? sizeof(*pval) : sizeof(ltmp)));-
174 return
executed 91 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 91 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
91
175}-
176-
177static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,-
178 int indent, const ASN1_PCTX *pctx)-
179{-
180 long l;-
181-
182 memcpy(&l, pval, (sizeof(*pval) < sizeof(l) ? sizeof(*pval) : sizeof(l)));-
183 return
executed 23 times by 1 test: return BIO_printf(out, "%ld\n", l);
Executed by:
  • libcrypto.so.1.1
BIO_printf(out, "%ld\n", l);
executed 23 times by 1 test: return BIO_printf(out, "%ld\n", l);
Executed by:
  • libcrypto.so.1.1
23
184}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2