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