| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509/by_file.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, | - | ||||||||||||||||||
| 5 | long argl, char **ret); | - | ||||||||||||||||||
| 6 | static X509_LOOKUP_METHOD x509_file_lookup = { | - | ||||||||||||||||||
| 7 | "Load file into cache", | - | ||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | ((void *)0) | - | ||||||||||||||||||
| 10 | , | - | ||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | ((void *)0) | - | ||||||||||||||||||
| 13 | , | - | ||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | ((void *)0) | - | ||||||||||||||||||
| 16 | , | - | ||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | ((void *)0) | - | ||||||||||||||||||
| 19 | , | - | ||||||||||||||||||
| 20 | by_file_ctrl, | - | ||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | ((void *)0) | - | ||||||||||||||||||
| 23 | , | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | ((void *)0) | - | ||||||||||||||||||
| 26 | , | - | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | ((void *)0) | - | ||||||||||||||||||
| 29 | , | - | ||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | ((void *)0) | - | ||||||||||||||||||
| 32 | , | - | ||||||||||||||||||
| 33 | }; | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | X509_LOOKUP_METHOD *X509_LOOKUP_file(void) | - | ||||||||||||||||||
| 36 | { | - | ||||||||||||||||||
| 37 | return executed 1801 times by 1 test: &x509_file_lookup;return &x509_file_lookup;Executed by:
executed 1801 times by 1 test: return &x509_file_lookup;Executed by:
| 1801 | ||||||||||||||||||
| 38 | } | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, | - | ||||||||||||||||||
| 41 | long argl, char **ret) | - | ||||||||||||||||||
| 42 | { | - | ||||||||||||||||||
| 43 | int ok = 0; | - | ||||||||||||||||||
| 44 | const char *file; | - | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | switch (cmd) { | - | ||||||||||||||||||
| 47 | case executed 1800 times by 1 test: 1:case 1:Executed by:
executed 1800 times by 1 test: case 1:Executed by:
| 1800 | ||||||||||||||||||
| 48 | if (argl == 3
| 442-1358 | ||||||||||||||||||
| 49 | file = getenv(X509_get_default_cert_file_env()); | - | ||||||||||||||||||
| 50 | if (file
| 0-442 | ||||||||||||||||||
| 51 | ok = (X509_load_cert_crl_file(ctx, file, never executed: ok = (X509_load_cert_crl_file(ctx, file, 1) != 0); | 0 | ||||||||||||||||||
| 52 | 1) != 0); never executed: ok = (X509_load_cert_crl_file(ctx, file, 1) != 0); | 0 | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | else | - | ||||||||||||||||||
| 55 | ok = (X509_load_cert_crl_file executed 442 times by 1 test: ok = (X509_load_cert_crl_file (ctx, X509_get_default_cert_file(), 1) != 0);Executed by:
| 442 | ||||||||||||||||||
| 56 | (ctx, X509_get_default_cert_file(), executed 442 times by 1 test: ok = (X509_load_cert_crl_file (ctx, X509_get_default_cert_file(), 1) != 0);Executed by:
| 442 | ||||||||||||||||||
| 57 | 1) != 0); executed 442 times by 1 test: ok = (X509_load_cert_crl_file (ctx, X509_get_default_cert_file(), 1) != 0);Executed by:
| 442 | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | if (!ok
| 0-442 | ||||||||||||||||||
| 60 | ERR_put_error(11,(101),(104),__FILE__,60); | - | ||||||||||||||||||
| 61 | } executed 442 times by 1 test: end of blockExecuted by:
| 442 | ||||||||||||||||||
| 62 | } executed 442 times by 1 test: else {end of blockExecuted by:
| 442 | ||||||||||||||||||
| 63 | if (argl == 1
| 0-1358 | ||||||||||||||||||
| 64 | ok = (X509_load_cert_crl_file(ctx, argp, executed 1358 times by 1 test: ok = (X509_load_cert_crl_file(ctx, argp, 1) != 0);Executed by:
| 1358 | ||||||||||||||||||
| 65 | 1) != 0); executed 1358 times by 1 test: ok = (X509_load_cert_crl_file(ctx, argp, 1) != 0);Executed by:
| 1358 | ||||||||||||||||||
| 66 | else | - | ||||||||||||||||||
| 67 | ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0); never executed: ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0); | 0 | ||||||||||||||||||
| 68 | } | - | ||||||||||||||||||
| 69 | break; executed 1800 times by 1 test: break;Executed by:
| 1800 | ||||||||||||||||||
| 70 | } | - | ||||||||||||||||||
| 71 | return executed 1800 times by 1 test: ok;return ok;Executed by:
executed 1800 times by 1 test: return ok;Executed by:
| 1800 | ||||||||||||||||||
| 72 | } | - | ||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) | - | ||||||||||||||||||
| 75 | { | - | ||||||||||||||||||
| 76 | int ret = 0; | - | ||||||||||||||||||
| 77 | BIO *in = | - | ||||||||||||||||||
| 78 | ((void *)0) | - | ||||||||||||||||||
| 79 | ; | - | ||||||||||||||||||
| 80 | int i, count = 0; | - | ||||||||||||||||||
| 81 | X509 *x = | - | ||||||||||||||||||
| 82 | ((void *)0) | - | ||||||||||||||||||
| 83 | ; | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | in = BIO_new(BIO_s_file()); | - | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | if ((
| 0-2 | ||||||||||||||||||
| 88 | ((void *)0)
| 0-2 | ||||||||||||||||||
| 89 | )
| 0-2 | ||||||||||||||||||
| 90 | ERR_put_error(11,(111),(2),__FILE__,84); | - | ||||||||||||||||||
| 91 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 92 | } | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | if (type == 1
| 0-2 | ||||||||||||||||||
| 95 | for (;;) { | - | ||||||||||||||||||
| 96 | x = PEM_read_bio_X509_AUX(in, | - | ||||||||||||||||||
| 97 | ((void *)0) | - | ||||||||||||||||||
| 98 | , | - | ||||||||||||||||||
| 99 | ((void *)0) | - | ||||||||||||||||||
| 100 | , ""); | - | ||||||||||||||||||
| 101 | if (x ==
| 2 | ||||||||||||||||||
| 102 | ((void *)0)
| 2 | ||||||||||||||||||
| 103 | ) { | - | ||||||||||||||||||
| 104 | if (((
| 0-2 | ||||||||||||||||||
| 105 | 108)
| 0-2 | ||||||||||||||||||
| 106 | ERR_clear_error(); | - | ||||||||||||||||||
| 107 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||
| 108 | } else { | - | ||||||||||||||||||
| 109 | ERR_put_error(11,(111),(9),__FILE__,97); | - | ||||||||||||||||||
| 110 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 111 | } | - | ||||||||||||||||||
| 112 | } | - | ||||||||||||||||||
| 113 | i = X509_STORE_add_cert(ctx->store_ctx, x); | - | ||||||||||||||||||
| 114 | if (!i
| 0-2 | ||||||||||||||||||
| 115 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 116 | count++; | - | ||||||||||||||||||
| 117 | X509_free(x); | - | ||||||||||||||||||
| 118 | x = | - | ||||||||||||||||||
| 119 | ((void *)0) | - | ||||||||||||||||||
| 120 | ; | - | ||||||||||||||||||
| 121 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 122 | ret = count; | - | ||||||||||||||||||
| 123 | } executed 2 times by 1 test: else if (type == 2end of blockExecuted by:
| 0-2 | ||||||||||||||||||
| 124 | x = d2i_X509_bio(in, | - | ||||||||||||||||||
| 125 | ((void *)0) | - | ||||||||||||||||||
| 126 | ); | - | ||||||||||||||||||
| 127 | if (x ==
| 0 | ||||||||||||||||||
| 128 | ((void *)0)
| 0 | ||||||||||||||||||
| 129 | ) { | - | ||||||||||||||||||
| 130 | ERR_put_error(11,(111),(13),__FILE__,112); | - | ||||||||||||||||||
| 131 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 132 | } | - | ||||||||||||||||||
| 133 | i = X509_STORE_add_cert(ctx->store_ctx, x); | - | ||||||||||||||||||
| 134 | if (!i
| 0 | ||||||||||||||||||
| 135 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 136 | ret = i; | - | ||||||||||||||||||
| 137 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 138 | ERR_put_error(11,(111),(100),__FILE__,120); | - | ||||||||||||||||||
| 139 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 140 | } | - | ||||||||||||||||||
| 141 | if (ret == 0
| 0-2 | ||||||||||||||||||
| 142 | ERR_put_error(11,(111),(135),__FILE__,124); never executed: ERR_put_error(11,(111),(135),__FILE__,124); | 0 | ||||||||||||||||||
| 143 | err: code before this statement executed 2 times by 1 test: err:Executed by:
| 2 | ||||||||||||||||||
| 144 | X509_free(x); | - | ||||||||||||||||||
| 145 | BIO_free(in); | - | ||||||||||||||||||
| 146 | return executed 2 times by 1 test: ret;return ret;Executed by:
executed 2 times by 1 test: return ret;Executed by:
| 2 | ||||||||||||||||||
| 147 | } | - | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) | - | ||||||||||||||||||
| 150 | { | - | ||||||||||||||||||
| 151 | int ret = 0; | - | ||||||||||||||||||
| 152 | BIO *in = | - | ||||||||||||||||||
| 153 | ((void *)0) | - | ||||||||||||||||||
| 154 | ; | - | ||||||||||||||||||
| 155 | int i, count = 0; | - | ||||||||||||||||||
| 156 | X509_CRL *x = | - | ||||||||||||||||||
| 157 | ((void *)0) | - | ||||||||||||||||||
| 158 | ; | - | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | in = BIO_new(BIO_s_file()); | - | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | if ((
| 0 | ||||||||||||||||||
| 163 | ((void *)0)
| 0 | ||||||||||||||||||
| 164 | )
| 0 | ||||||||||||||||||
| 165 | ERR_put_error(11,(112),(2),__FILE__,141); | - | ||||||||||||||||||
| 166 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 167 | } | - | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | if (type == 1
| 0 | ||||||||||||||||||
| 170 | for (;;) { | - | ||||||||||||||||||
| 171 | x = PEM_read_bio_X509_CRL(in, | - | ||||||||||||||||||
| 172 | ((void *)0) | - | ||||||||||||||||||
| 173 | , | - | ||||||||||||||||||
| 174 | ((void *)0) | - | ||||||||||||||||||
| 175 | , ""); | - | ||||||||||||||||||
| 176 | if (x ==
| 0 | ||||||||||||||||||
| 177 | ((void *)0)
| 0 | ||||||||||||||||||
| 178 | ) { | - | ||||||||||||||||||
| 179 | if (((
| 0 | ||||||||||||||||||
| 180 | 108)
| 0 | ||||||||||||||||||
| 181 | ERR_clear_error(); | - | ||||||||||||||||||
| 182 | break; never executed: break; | 0 | ||||||||||||||||||
| 183 | } else { | - | ||||||||||||||||||
| 184 | ERR_put_error(11,(112),(9),__FILE__,154); | - | ||||||||||||||||||
| 185 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 186 | } | - | ||||||||||||||||||
| 187 | } | - | ||||||||||||||||||
| 188 | i = X509_STORE_add_crl(ctx->store_ctx, x); | - | ||||||||||||||||||
| 189 | if (!i
| 0 | ||||||||||||||||||
| 190 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 191 | count++; | - | ||||||||||||||||||
| 192 | X509_CRL_free(x); | - | ||||||||||||||||||
| 193 | x = | - | ||||||||||||||||||
| 194 | ((void *)0) | - | ||||||||||||||||||
| 195 | ; | - | ||||||||||||||||||
| 196 | } never executed: end of block | 0 | ||||||||||||||||||
| 197 | ret = count; | - | ||||||||||||||||||
| 198 | } never executed: else if (type == 2end of block
| 0 | ||||||||||||||||||
| 199 | x = d2i_X509_CRL_bio(in, | - | ||||||||||||||||||
| 200 | ((void *)0) | - | ||||||||||||||||||
| 201 | ); | - | ||||||||||||||||||
| 202 | if (x ==
| 0 | ||||||||||||||||||
| 203 | ((void *)0)
| 0 | ||||||||||||||||||
| 204 | ) { | - | ||||||||||||||||||
| 205 | ERR_put_error(11,(112),(13),__FILE__,169); | - | ||||||||||||||||||
| 206 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 207 | } | - | ||||||||||||||||||
| 208 | i = X509_STORE_add_crl(ctx->store_ctx, x); | - | ||||||||||||||||||
| 209 | if (!i
| 0 | ||||||||||||||||||
| 210 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 211 | ret = i; | - | ||||||||||||||||||
| 212 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 213 | ERR_put_error(11,(112),(100),__FILE__,177); | - | ||||||||||||||||||
| 214 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 215 | } | - | ||||||||||||||||||
| 216 | if (ret == 0
| 0 | ||||||||||||||||||
| 217 | ERR_put_error(11,(112),(137),__FILE__,181); never executed: ERR_put_error(11,(112),(137),__FILE__,181); | 0 | ||||||||||||||||||
| 218 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||
| 219 | X509_CRL_free(x); | - | ||||||||||||||||||
| 220 | BIO_free(in); | - | ||||||||||||||||||
| 221 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 222 | } | - | ||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type) | - | ||||||||||||||||||
| 225 | { | - | ||||||||||||||||||
| 226 | struct stack_st_X509_INFO *inf; | - | ||||||||||||||||||
| 227 | X509_INFO *itmp; | - | ||||||||||||||||||
| 228 | BIO *in; | - | ||||||||||||||||||
| 229 | int i, count = 0; | - | ||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | if (type != 1
| 0-1800 | ||||||||||||||||||
| 232 | return never executed: X509_load_cert_file(ctx, file, type);return X509_load_cert_file(ctx, file, type);never executed: return X509_load_cert_file(ctx, file, type); | 0 | ||||||||||||||||||
| 233 | in = BIO_new_file(file, "r"); | - | ||||||||||||||||||
| 234 | if (!in
| 442-1358 | ||||||||||||||||||
| 235 | ERR_put_error(11,(132),(2),__FILE__,199); | - | ||||||||||||||||||
| 236 | return executed 442 times by 1 test: 0;return 0;Executed by:
executed 442 times by 1 test: return 0;Executed by:
| 442 | ||||||||||||||||||
| 237 | } | - | ||||||||||||||||||
| 238 | inf = PEM_X509_INFO_read_bio(in, | - | ||||||||||||||||||
| 239 | ((void *)0) | - | ||||||||||||||||||
| 240 | , | - | ||||||||||||||||||
| 241 | ((void *)0) | - | ||||||||||||||||||
| 242 | , ""); | - | ||||||||||||||||||
| 243 | BIO_free(in); | - | ||||||||||||||||||
| 244 | if (!inf
| 0-1358 | ||||||||||||||||||
| 245 | ERR_put_error(11,(132),(9),__FILE__,205); | - | ||||||||||||||||||
| 246 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 247 | } | - | ||||||||||||||||||
| 248 | for (i = 0; i < sk_X509_INFO_num(inf)
| 1358-1366 | ||||||||||||||||||
| 249 | itmp = sk_X509_INFO_value(inf, i); | - | ||||||||||||||||||
| 250 | if (itmp->x509
| 0-1366 | ||||||||||||||||||
| 251 | if (!X509_STORE_add_cert(ctx->store_ctx, itmp->x509)
| 0-1366 | ||||||||||||||||||
| 252 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 253 | count++; | - | ||||||||||||||||||
| 254 | } executed 1366 times by 1 test: end of blockExecuted by:
| 1366 | ||||||||||||||||||
| 255 | if (itmp->crl
| 0-1366 | ||||||||||||||||||
| 256 | if (!X509_STORE_add_crl(ctx->store_ctx, itmp->crl)
| 0 | ||||||||||||||||||
| 257 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||
| 258 | count++; | - | ||||||||||||||||||
| 259 | } never executed: end of block | 0 | ||||||||||||||||||
| 260 | } executed 1366 times by 1 test: end of blockExecuted by:
| 1366 | ||||||||||||||||||
| 261 | if (count == 0
| 0-1358 | ||||||||||||||||||
| 262 | ERR_put_error(11,(132),(136),__FILE__,223) never executed: ERR_put_error(11,(132),(136),__FILE__,223) ; | 0 | ||||||||||||||||||
| 263 | ; never executed: ERR_put_error(11,(132),(136),__FILE__,223) ; | 0 | ||||||||||||||||||
| 264 | err: code before this statement executed 1358 times by 1 test: err:Executed by:
| 1358 | ||||||||||||||||||
| 265 | sk_X509_INFO_pop_free(inf, X509_INFO_free); | - | ||||||||||||||||||
| 266 | return executed 1358 times by 1 test: count;return count;Executed by:
executed 1358 times by 1 test: return count;Executed by:
| 1358 | ||||||||||||||||||
| 267 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |