OpenCoverage

buffer.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/buffer/buffer.c
Switch to Source codePreprocessed file
LineSourceCount
1BUF_MEM *BUF_MEM_new_ex(unsigned long flags)-
2{-
3 BUF_MEM *ret;-
4-
5 ret = BUF_MEM_new();-
6 if (ret !=
ret != ((void *)0)Description
TRUEevaluated 111695 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-111695
7 ((void *)0)
ret != ((void *)0)Description
TRUEevaluated 111695 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-111695
8 )-
9 ret->flags = flags;
executed 111695 times by 1 test: ret->flags = flags;
Executed by:
  • libcrypto.so.1.1
111695
10 return
executed 111695 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 111695 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
111695
11}-
12-
13BUF_MEM *BUF_MEM_new(void)-
14{-
15 BUF_MEM *ret;-
16-
17 ret = CRYPTO_zalloc(sizeof(*ret), __FILE__, 35);-
18 if (ret ==
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 520915 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-520915
19 ((void *)0)
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 520915 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-520915
20 ) {-
21 ERR_put_error(7,(101),((1|64)),__FILE__,37);-
22 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
23 ((void *)0)
never executed: return ((void *)0) ;
0
24 ;
never executed: return ((void *)0) ;
0
25 }-
26 return
executed 520915 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 520915 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
520915
27}-
28-
29void BUF_MEM_free(BUF_MEM *a)-
30{-
31 if (a ==
a == ((void *)0)Description
TRUEevaluated 48617 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 400405 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
48617-400405
32 ((void *)0)
a == ((void *)0)Description
TRUEevaluated 48617 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 400405 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
48617-400405
33 )-
34 return;
executed 48617 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
48617
35 if (a->data !=
a->data != ((void *)0)Description
TRUEevaluated 185075 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 215330 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
185075-215330
36 ((void *)0)
a->data != ((void *)0)Description
TRUEevaluated 185075 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 215330 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
185075-215330
37 ) {-
38 if (a->flags & 0x01
a->flags & 0x01Description
TRUEevaluated 7751 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 177324 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
7751-177324
39 CRYPTO_secure_clear_free(a->data, a->max, __FILE__, 49);
executed 7751 times by 1 test: CRYPTO_secure_clear_free(a->data, a->max, __FILE__, 49);
Executed by:
  • libcrypto.so.1.1
7751
40 else-
41 CRYPTO_clear_free(a->data, a->max, __FILE__, 51);
executed 177324 times by 1 test: CRYPTO_clear_free(a->data, a->max, __FILE__, 51);
Executed by:
  • libcrypto.so.1.1
177324
42 }-
43 CRYPTO_free(a, __FILE__, 53);-
44}
executed 400405 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
400405
45-
46-
47-
48static char *sec_alloc_realloc(BUF_MEM *str, size_t len)-
49{-
50 char *ret;-
51-
52 ret = CRYPTO_secure_malloc(len, __FILE__, 62);-
53 if (str->data !=
str->data != ((void *)0)Description
TRUEevaluated 33012 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7751 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7751-33012
54 ((void *)0)
str->data != ((void *)0)Description
TRUEevaluated 33012 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7751 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7751-33012
55 ) {-
56 if (ret !=
ret != ((void *)0)Description
TRUEevaluated 33012 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-33012
57 ((void *)0)
ret != ((void *)0)Description
TRUEevaluated 33012 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-33012
58 ) {-
59 memcpy(ret, str->data, str->length);-
60 CRYPTO_secure_clear_free(str->data, str->length, __FILE__, 66);-
61 str->data = -
62 ((void *)0)-
63 ;-
64 }
executed 33012 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
33012
65 }
executed 33012 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
33012
66 return
executed 40763 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 40763 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
40763
67}-
68-
69size_t BUF_MEM_grow(BUF_MEM *str, size_t len)-
70{-
71 char *ret;-
72 size_t n;-
73-
74 if (str->length >= len
str->length >= lenDescription
TRUEevaluated 168621 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 279011 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
168621-279011
75 str->length = len;-
76 return
executed 168621 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
len;
executed 168621 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
168621
77 }-
78 if (str->max >= len
str->max >= lenDescription
TRUEevaluated 18361 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 260650 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
18361-260650
79 if (str->data !=
str->data != ((void *)0)Description
TRUEevaluated 18361 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-18361
80 ((void *)0)
str->data != ((void *)0)Description
TRUEevaluated 18361 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-18361
81 )-
82 memset(&str->data[str->length], 0, len - str->length);
executed 18361 times by 1 test: memset(&str->data[str->length], 0, len - str->length);
Executed by:
  • libcrypto.so.1.1
18361
83 str->length = len;-
84 return
executed 18361 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
len;
executed 18361 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
18361
85 }-
86-
87 if (len > 0x5ffffffc
len > 0x5ffffffcDescription
TRUEnever evaluated
FALSEevaluated 260650 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-260650
88 ERR_put_error(7,(100),((1|64)),__FILE__,90);-
89 return
never executed: return 0;
0;
never executed: return 0;
0
90 }-
91 n = (len + 3) / 3 * 4;-
92 if ((
(str->flags & 0x01)Description
TRUEnever evaluated
FALSEevaluated 260650 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
str->flags & 0x01)
(str->flags & 0x01)Description
TRUEnever evaluated
FALSEevaluated 260650 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-260650
93 ret = sec_alloc_realloc(str, n);
never executed: ret = sec_alloc_realloc(str, n);
0
94 else-
95 ret = CRYPTO_realloc(str->data, n, __FILE__, 97);
executed 260650 times by 1 test: ret = CRYPTO_realloc(str->data, n, __FILE__, 97);
Executed by:
  • libcrypto.so.1.1
260650
96 if (ret ==
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 260650 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-260650
97 ((void *)0)
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 260650 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-260650
98 ) {-
99 ERR_put_error(7,(100),((1|64)),__FILE__,99);-
100 len = 0;-
101 }
never executed: end of block
else {
0
102 str->data = ret;-
103 str->max = n;-
104 memset(&str->data[str->length], 0, len - str->length);-
105 str->length = len;-
106 }
executed 260650 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
260650
107 return
executed 260650 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
len;
executed 260650 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
260650
108}-
109-
110size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len)-
111{-
112 char *ret;-
113 size_t n;-
114-
115 if (str->length >= len
str->length >= lenDescription
TRUEevaluated 25688 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1016139 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
25688-1016139
116 if (str->data !=
str->data != ((void *)0)Description
TRUEevaluated 25688 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-25688
117 ((void *)0)
str->data != ((void *)0)Description
TRUEevaluated 25688 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-25688
118 )-
119 memset(&str->data[len], 0, str->length - len);
executed 25688 times by 1 test: memset(&str->data[len], 0, str->length - len);
Executed by:
  • libcrypto.so.1.1
25688
120 str->length = len;-
121 return
executed 25688 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
len;
executed 25688 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
25688
122 }-
123 if (str->max >= len
str->max >= lenDescription
TRUEevaluated 785629 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 230510 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
230510-785629
124 memset(&str->data[str->length], 0, len - str->length);-
125 str->length = len;-
126 return
executed 785629 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
len;
executed 785629 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
785629
127 }-
128-
129 if (len > 0x5ffffffc
len > 0x5ffffffcDescription
TRUEnever evaluated
FALSEevaluated 230510 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-230510
130 ERR_put_error(7,(105),((1|64)),__FILE__,128);-
131 return
never executed: return 0;
0;
never executed: return 0;
0
132 }-
133 n = (len + 3) / 3 * 4;-
134 if ((
(str->flags & 0x01)Description
TRUEevaluated 40763 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 189747 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
str->flags & 0x01)
(str->flags & 0x01)Description
TRUEevaluated 40763 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 189747 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
40763-189747
135 ret = sec_alloc_realloc(str, n);
executed 40763 times by 1 test: ret = sec_alloc_realloc(str, n);
Executed by:
  • libcrypto.so.1.1
40763
136 else-
137 ret = CRYPTO_clear_realloc(str->data, str->max, n, __FILE__, 135);
executed 189747 times by 1 test: ret = CRYPTO_clear_realloc(str->data, str->max, n, __FILE__, 135);
Executed by:
  • libcrypto.so.1.1
189747
138 if (ret ==
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 230510 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-230510
139 ((void *)0)
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 230510 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-230510
140 ) {-
141 ERR_put_error(7,(105),((1|64)),__FILE__,137);-
142 len = 0;-
143 }
never executed: end of block
else {
0
144 str->data = ret;-
145 str->max = n;-
146 memset(&str->data[str->length], 0, len - str->length);-
147 str->length = len;-
148 }
executed 230510 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
230510
149 return
executed 230510 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
len;
executed 230510 times by 1 test: return len;
Executed by:
  • libcrypto.so.1.1
230510
150}-
151-
152void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size)-
153{-
154 size_t i;-
155 if (in
inDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 123 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
3-123
156 out += size - 1;-
157 for (i = 0; i < size
i < sizeDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++)
3-24
158 *
executed 24 times by 1 test: *out-- = *in++;
Executed by:
  • libcrypto.so.1.1
out-- = *in++;
executed 24 times by 1 test: *out-- = *in++;
Executed by:
  • libcrypto.so.1.1
24
159 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
3
160 unsigned char *q;-
161 char c;-
162 q = out + size - 1;-
163 for (i = 0; i < size / 2
i < size / 2Description
TRUEevaluated 348 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 123 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i++) {
123-348
164 c = *q;-
165 *q-- = *out;-
166 *out++ = c;-
167 }
executed 348 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
348
168 }
executed 123 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
123
169}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2