OpenCoverage

ui_util.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ui/ui_util.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,-
7 int verify)-
8{-
9 char buff[-
10 8192-
11 ];-
12 int ret;-
13-
14 ret =-
15 UI_UTIL_read_pw(buf, buff, (length > -
16 8192-
17 ) ? -
18 8192 -
19 : length,-
20 prompt, verify);-
21 OPENSSL_cleanse(buff, -
22 8192-
23 );-
24 return
never executed: return ret;
ret;
never executed: return ret;
0
25}-
26-
27int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,-
28 int verify)-
29{-
30 int ok = 0;-
31 UI *ui;-
32-
33 if (size < 1
size < 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
34 return
never executed: return -1;
-1;
never executed: return -1;
0
35-
36 ui = UI_new();-
37 if (ui !=
ui != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
38 ((void *)0)
ui != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
39 ) {-
40 ok = UI_add_input_string(ui, prompt, 0, buf, 0, size - 1);-
41 if (ok >= 0
ok >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& verify
verifyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
42 ok = UI_add_verify_string(ui, prompt, 0, buff, 0, size - 1, buf);
never executed: ok = UI_add_verify_string(ui, prompt, 0, buff, 0, size - 1, buf);
0
43 if (ok >= 0
ok >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
44 ok = UI_process(ui);
never executed: ok = UI_process(ui);
0
45 UI_free(ui);-
46 }
never executed: end of block
0
47 if (ok > 0
ok > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
48 ok = 0;
never executed: ok = 0;
0
49 return
never executed: return ok;
ok;
never executed: return ok;
0
50}-
51-
52-
53-
54-
55-
56struct pem_password_cb_data {-
57 pem_password_cb *cb;-
58 int rwflag;-
59};-
60-
61static void ui_new_method_data(void *parent, void *ptr, CRYPTO_EX_DATA *ad,-
62 int idx, long argl, void *argp)-
63{-
64-
65-
66-
67-
68}-
69-
70static int ui_dup_method_data(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,-
71 void *from_d, int idx, long argl, void *argp)-
72{-
73 void **pptr = (void **)from_d;-
74 if (*
*pptr != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
pptr !=
*pptr != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
75 ((void *)0)
*pptr != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
76 )-
77 *
never executed: *pptr = CRYPTO_memdup((*pptr), sizeof(struct pem_password_cb_data), __FILE__, 77);
pptr = CRYPTO_memdup((*pptr), sizeof(struct pem_password_cb_data), __FILE__, 77);
never executed: *pptr = CRYPTO_memdup((*pptr), sizeof(struct pem_password_cb_data), __FILE__, 77);
0
78 return
never executed: return 1;
1;
never executed: return 1;
0
79}-
80-
81static void ui_free_method_data(void *parent, void *ptr, CRYPTO_EX_DATA *ad,-
82 int idx, long argl, void *argp)-
83{-
84 CRYPTO_free(ptr, __FILE__, 84);-
85}
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
86-
87static CRYPTO_ONCE get_index_once = -
88 0-
89 ;-
90static int ui_method_data_index = -1;-
91static int ui_method_data_index_init(void); static int ui_method_data_index_init_ossl_ret_ = 0; static void ui_method_data_index_init_ossl_(void) { ui_method_data_index_init_ossl_ret_ = ui_method_data_index_init(); }
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
static int ui_method_data_index_init(void)
1
92{-
93 ui_method_data_index = CRYPTO_get_ex_new_index(14,-
94 0, -
95 ((void *)0)-
96 , ui_new_method_data,-
97 ui_dup_method_data,-
98 ui_free_method_data);-
99 return
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1
100}-
101-
102static int ui_open(UI *ui)-
103{-
104 return
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1
105}-
106static int ui_read(UI *ui, UI_STRING *uis)-
107{-
108 switch (UI_get_string_type(uis)) {-
109 case
executed 1 time by 1 test: case UIT_PROMPT:
Executed by:
  • libcrypto.so.1.1
UIT_PROMPT:
executed 1 time by 1 test: case UIT_PROMPT:
Executed by:
  • libcrypto.so.1.1
1
110 {-
111 char result[1024 + 1];-
112 const struct pem_password_cb_data *data =-
113 UI_method_get_ex_data(UI_get_method(ui), ui_method_data_index);-
114 int maxsize = UI_get_result_maxsize(uis);-
115 int len = data->cb(result,-
116 maxsize > 1024 ? 1024 : maxsize,-
117 data->rwflag, UI_get0_user_data(ui));-
118-
119 if (len >= 0
len >= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-1
120 result[len] = '\0';
executed 1 time by 1 test: result[len] = '\0';
Executed by:
  • libcrypto.so.1.1
1
121 if (len <= 0
len <= 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-1
122 return
never executed: return len;
len;
never executed: return len;
0
123 if (UI_set_result_ex(ui, uis, result, len) >= 0
UI_set_result_...ult, len) >= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-1
124 return
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1
125 return
never executed: return 0;
0;
never executed: return 0;
0
126 }-
127 case
never executed: case UIT_VERIFY:
UIT_VERIFY:
never executed: case UIT_VERIFY:
0
128 case
never executed: case UIT_NONE:
UIT_NONE:
never executed: case UIT_NONE:
0
129 case
never executed: case UIT_BOOLEAN:
UIT_BOOLEAN:
never executed: case UIT_BOOLEAN:
0
130 case
never executed: case UIT_INFO:
UIT_INFO:
never executed: case UIT_INFO:
0
131 case
never executed: case UIT_ERROR:
UIT_ERROR:
never executed: case UIT_ERROR:
0
132 break;
never executed: break;
0
133 }-
134 return
never executed: return 1;
1;
never executed: return 1;
0
135}-
136static int ui_write(UI *ui, UI_STRING *uis)-
137{-
138 return
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1
139}-
140static int ui_close(UI *ui)-
141{-
142 return
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1
143}-
144-
145UI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag)-
146{-
147 struct pem_password_cb_data *data = -
148 ((void *)0)-
149 ;-
150 UI_METHOD *ui_method = -
151 ((void *)0)-
152 ;-
153-
154 if ((
(data = CRYPTO...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
data = CRYPTO_zalloc(sizeof(*data), __FILE__, 146)) ==
(data = CRYPTO...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
155 ((void *)0)
(data = CRYPTO...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
156 -
157 || (
(ui_method = U...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
ui_method = UI_create_method("PEM password callback wrapper")) ==
(ui_method = U...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
158 ((void *)0)
(ui_method = U...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
159 -
160 || UI_method_set_opener(ui_method, ui_open) < 0
UI_method_set_..., ui_open) < 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
161 || UI_method_set_reader(ui_method, ui_read) < 0
UI_method_set_..., ui_read) < 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
162 || UI_method_set_writer(ui_method, ui_write) < 0
UI_method_set_... ui_write) < 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
163 || UI_method_set_closer(ui_method, ui_close) < 0
UI_method_set_... ui_close) < 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
164 || !(CRYPTO_THREAD_run_once(&get_index_once, ui_method_data_index_init_ossl_) ? ui_method_data_index_init_ossl_ret_ : 0)
!(CRYPTO_THREA...ossl_ret_ : 0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
165 || UI_method_set_ex_data(ui_method, ui_method_data_index, data) < 0
UI_method_set_...dex, data) < 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-1
166 UI_destroy_method(ui_method);-
167 CRYPTO_free(data, __FILE__, 155);-
168 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
169 ((void *)0)
never executed: return ((void *)0) ;
0
170 ;
never executed: return ((void *)0) ;
0
171 }-
172 data->rwflag = rwflag;-
173 data->cb = cb;-
174-
175 return
executed 1 time by 1 test: return ui_method;
Executed by:
  • libcrypto.so.1.1
ui_method;
executed 1 time by 1 test: return ui_method;
Executed by:
  • libcrypto.so.1.1
1
176}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2