| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/tasn_prn.c | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||
| 2 | * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||
| 3 | * | - | ||||||||||||
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||
| 5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||
| 6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||
| 7 | * https://www.openssl.org/source/license.html | - | ||||||||||||
| 8 | */ | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | #include <stddef.h> | - | ||||||||||||
| 11 | #include "internal/cryptlib.h" | - | ||||||||||||
| 12 | #include <openssl/asn1.h> | - | ||||||||||||
| 13 | #include <openssl/asn1t.h> | - | ||||||||||||
| 14 | #include <openssl/objects.h> | - | ||||||||||||
| 15 | #include <openssl/buffer.h> | - | ||||||||||||
| 16 | #include <openssl/err.h> | - | ||||||||||||
| 17 | #include <openssl/x509v3.h> | - | ||||||||||||
| 18 | #include "internal/asn1_int.h" | - | ||||||||||||
| 19 | #include "asn1_locl.h" | - | ||||||||||||
| 20 | - | |||||||||||||
| 21 | /* | - | ||||||||||||
| 22 | * Print routines. | - | ||||||||||||
| 23 | */ | - | ||||||||||||
| 24 | - | |||||||||||||
| 25 | /* ASN1_PCTX routines */ | - | ||||||||||||
| 26 | - | |||||||||||||
| 27 | static ASN1_PCTX default_pctx = { | - | ||||||||||||
| 28 | ASN1_PCTX_FLAGS_SHOW_ABSENT, /* flags */ | - | ||||||||||||
| 29 | 0, /* nm_flags */ | - | ||||||||||||
| 30 | 0, /* cert_flags */ | - | ||||||||||||
| 31 | 0, /* oid_flags */ | - | ||||||||||||
| 32 | 0 /* str_flags */ | - | ||||||||||||
| 33 | }; | - | ||||||||||||
| 34 | - | |||||||||||||
| 35 | ASN1_PCTX *ASN1_PCTX_new(void) | - | ||||||||||||
| 36 | { | - | ||||||||||||
| 37 | ASN1_PCTX *ret; | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | ret = OPENSSL_zalloc(sizeof(*ret)); | - | ||||||||||||
| 40 | if (ret == NULL) { 
 | 0-1 | ||||||||||||
| 41 | ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 42 | return NULL; never executed:  return ((void *)0) ; | 0 | ||||||||||||
| 43 | } | - | ||||||||||||
| 44 | return ret; executed 1 time by 1 test:  return ret;Executed by: 
 | 1 | ||||||||||||
| 45 | } | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | void ASN1_PCTX_free(ASN1_PCTX *p) | - | ||||||||||||
| 48 | { | - | ||||||||||||
| 49 | OPENSSL_free(p); | - | ||||||||||||
| 50 | } executed 1 time by 1 test:  end of blockExecuted by: 
 | 1 | ||||||||||||
| 51 | - | |||||||||||||
| 52 | unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p) | - | ||||||||||||
| 53 | { | - | ||||||||||||
| 54 | return p->flags; never executed:  return p->flags; | 0 | ||||||||||||
| 55 | } | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags) | - | ||||||||||||
| 58 | { | - | ||||||||||||
| 59 | p->flags = flags; | - | ||||||||||||
| 60 | } executed 1 time by 1 test:  end of blockExecuted by: 
 | 1 | ||||||||||||
| 61 | - | |||||||||||||
| 62 | unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p) | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | return p->nm_flags; never executed:  return p->nm_flags; | 0 | ||||||||||||
| 65 | } | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags) | - | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 | p->nm_flags = flags; | - | ||||||||||||
| 70 | } never executed:  end of block | 0 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p) | - | ||||||||||||
| 73 | { | - | ||||||||||||
| 74 | return p->cert_flags; never executed:  return p->cert_flags; | 0 | ||||||||||||
| 75 | } | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags) | - | ||||||||||||
| 78 | { | - | ||||||||||||
| 79 | p->cert_flags = flags; | - | ||||||||||||
| 80 | } never executed:  end of block | 0 | ||||||||||||
| 81 | - | |||||||||||||
| 82 | unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | return p->oid_flags; never executed:  return p->oid_flags; | 0 | ||||||||||||
| 85 | } | - | ||||||||||||
| 86 | - | |||||||||||||
| 87 | void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags) | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | p->oid_flags = flags; | - | ||||||||||||
| 90 | } never executed:  end of block | 0 | ||||||||||||
| 91 | - | |||||||||||||
| 92 | unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p) | - | ||||||||||||
| 93 | { | - | ||||||||||||
| 94 | return p->str_flags; never executed:  return p->str_flags; | 0 | ||||||||||||
| 95 | } | - | ||||||||||||
| 96 | - | |||||||||||||
| 97 | void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags) | - | ||||||||||||
| 98 | { | - | ||||||||||||
| 99 | p->str_flags = flags; | - | ||||||||||||
| 100 | } executed 1 time by 1 test:  end of blockExecuted by: 
 | 1 | ||||||||||||
| 101 | - | |||||||||||||
| 102 | /* Main print routines */ | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, | - | ||||||||||||
| 105 | const ASN1_ITEM *it, | - | ||||||||||||
| 106 | const char *fname, const char *sname, | - | ||||||||||||
| 107 | int nohdr, const ASN1_PCTX *pctx); | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, | - | ||||||||||||
| 110 | const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx); | - | ||||||||||||
| 111 | - | |||||||||||||
| 112 | static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld, | - | ||||||||||||
| 113 | const ASN1_ITEM *it, int indent, | - | ||||||||||||
| 114 | const char *fname, const char *sname, | - | ||||||||||||
| 115 | const ASN1_PCTX *pctx); | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | static int asn1_print_fsname(BIO *out, int indent, | - | ||||||||||||
| 118 | const char *fname, const char *sname, | - | ||||||||||||
| 119 | const ASN1_PCTX *pctx); | - | ||||||||||||
| 120 | - | |||||||||||||
| 121 | int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, | - | ||||||||||||
| 122 | const ASN1_ITEM *it, const ASN1_PCTX *pctx) | - | ||||||||||||
| 123 | { | - | ||||||||||||
| 124 | const char *sname; | - | ||||||||||||
| 125 | if (pctx == NULL) 
 | 5-10772 | ||||||||||||
| 126 | pctx = &default_pctx; executed 5 times by 1 test:  pctx = &default_pctx;Executed by: 
 | 5 | ||||||||||||
| 127 | if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) 
 | 0-10777 | ||||||||||||
| 128 | sname = NULL; never executed:  sname = ((void *)0) ; | 0 | ||||||||||||
| 129 | else | - | ||||||||||||
| 130 | sname = it->sname; executed 10777 times by 1 test:  sname = it->sname;Executed by: 
 | 10777 | ||||||||||||
| 131 | return asn1_item_print_ctx(out, &ifld, indent, it, NULL, sname, 0, pctx); executed 10777 times by 1 test:  return asn1_item_print_ctx(out, &ifld, indent, it, ((void *)0) , sname, 0, pctx);Executed by: 
 | 10777 | ||||||||||||
| 132 | } | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, | - | ||||||||||||
| 135 | const ASN1_ITEM *it, | - | ||||||||||||
| 136 | const char *fname, const char *sname, | - | ||||||||||||
| 137 | int nohdr, const ASN1_PCTX *pctx) | - | ||||||||||||
| 138 | { | - | ||||||||||||
| 139 | const ASN1_TEMPLATE *tt; | - | ||||||||||||
| 140 | const ASN1_EXTERN_FUNCS *ef; | - | ||||||||||||
| 141 | ASN1_VALUE **tmpfld; | - | ||||||||||||
| 142 | const ASN1_AUX *aux = it->funcs; | - | ||||||||||||
| 143 | ASN1_aux_cb *asn1_cb; | - | ||||||||||||
| 144 | ASN1_PRINT_ARG parg; | - | ||||||||||||
| 145 | int i; | - | ||||||||||||
| 146 | if (aux && aux->asn1_cb) { 
 
 | 1167-79041 | ||||||||||||
| 147 | parg.out = out; | - | ||||||||||||
| 148 | parg.indent = indent; | - | ||||||||||||
| 149 | parg.pctx = pctx; | - | ||||||||||||
| 150 | asn1_cb = aux->asn1_cb; | - | ||||||||||||
| 151 | } else executed 15513 times by 1 test:  end of blockExecuted by: 
 | 15513 | ||||||||||||
| 152 | asn1_cb = 0; executed 80208 times by 1 test:  asn1_cb = 0;Executed by: 
 | 80208 | ||||||||||||
| 153 | - | |||||||||||||
| 154 | if (((it->itype != ASN1_ITYPE_PRIMITIVE) 
 | 27811-67910 | ||||||||||||
| 155 | || (it->utype != V_ASN1_BOOLEAN)) && *fld == NULL) { 
 
 | 2434-88442 | ||||||||||||
| 156 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) { 
 | 0-4845 | ||||||||||||
| 157 | if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) 
 
 | 0-4845 | ||||||||||||
| 158 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 159 | if (BIO_puts(out, "<ABSENT>\n") <= 0) 
 | 0-4845 | ||||||||||||
| 160 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 161 | } executed 4845 times by 1 test:  end of blockExecuted by: 
 | 4845 | ||||||||||||
| 162 | return 1; executed 4845 times by 1 test:  return 1;Executed by: 
 | 4845 | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | switch (it->itype) { | - | ||||||||||||
| 166 | case ASN1_ITYPE_PRIMITIVE: executed 64451 times by 1 test:  case 0x0:Executed by: 
 | 64451 | ||||||||||||
| 167 | if (it->templates) { 
 | 2581-61870 | ||||||||||||
| 168 | if (!asn1_template_print_ctx(out, fld, indent, 
 | 154-2427 | ||||||||||||
| 169 | it->templates, pctx)) 
 | 154-2427 | ||||||||||||
| 170 | return 0; executed 154 times by 1 test:  return 0;Executed by: 
 | 154 | ||||||||||||
| 171 | break; executed 2427 times by 1 test:  break;Executed by: 
 | 2427 | ||||||||||||
| 172 | } | - | ||||||||||||
| 173 | /* fall through */ | - | ||||||||||||
| 174 | case ASN1_ITYPE_MSTRING: code before this statement executed 61870 times by 1 test:  case 0x5:Executed by: 
 executed 3871 times by 1 test:  case 0x5:Executed by: 
 | 3871-61870 | ||||||||||||
| 175 | if (!asn1_primitive_print(out, fld, it, indent, fname, sname, pctx)) 
 | 1211-64530 | ||||||||||||
| 176 | return 0; executed 1211 times by 1 test:  return 0;Executed by: 
 | 1211 | ||||||||||||
| 177 | break; executed 64530 times by 1 test:  break;Executed by: 
 | 64530 | ||||||||||||
| 178 | - | |||||||||||||
| 179 | case ASN1_ITYPE_EXTERN: executed 1163 times by 1 test:  case 0x4:Executed by: 
 | 1163 | ||||||||||||
| 180 | if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) 
 
 | 0-1163 | ||||||||||||
| 181 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 182 | /* Use new style print routine if possible */ | - | ||||||||||||
| 183 | ef = it->funcs; | - | ||||||||||||
| 184 | if (ef && ef->asn1_ex_print) { 
 
 | 0-1163 | ||||||||||||
| 185 | i = ef->asn1_ex_print(out, fld, indent, "", pctx); | - | ||||||||||||
| 186 | if (!i) 
 | 0-1163 | ||||||||||||
| 187 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 188 | if ((i == 2) && (BIO_puts(out, "\n") <= 0)) 
 
 | 0-1163 | ||||||||||||
| 189 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 190 | return 1; executed 1163 times by 1 test:  return 1;Executed by: 
 | 1163 | ||||||||||||
| 191 | } else if (sname && 
 | 0 | ||||||||||||
| 192 | BIO_printf(out, ":EXTERNAL TYPE %s\n", sname) <= 0) 
 | 0 | ||||||||||||
| 193 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 194 | break; never executed:  break; | 0 | ||||||||||||
| 195 | - | |||||||||||||
| 196 | case ASN1_ITYPE_CHOICE: executed 4292 times by 1 test:  case 0x2:Executed by: 
 | 4292 | ||||||||||||
| 197 | /* CHOICE type, get selector */ | - | ||||||||||||
| 198 | i = asn1_get_choice_selector(fld, it); | - | ||||||||||||
| 199 | /* This should never happen... */ | - | ||||||||||||
| 200 | if ((i < 0) || (i >= it->tcount)) { 
 
 | 0-4292 | ||||||||||||
| 201 | if (BIO_printf(out, "ERROR: selector [%d] invalid\n", i) <= 0) 
 | 0 | ||||||||||||
| 202 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 203 | return 1; never executed:  return 1; | 0 | ||||||||||||
| 204 | } | - | ||||||||||||
| 205 | tt = it->templates + i; | - | ||||||||||||
| 206 | tmpfld = asn1_get_field_ptr(fld, tt); | - | ||||||||||||
| 207 | if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx)) 
 | 46-4246 | ||||||||||||
| 208 | return 0; executed 46 times by 1 test:  return 0;Executed by: 
 | 46 | ||||||||||||
| 209 | break; executed 4246 times by 1 test:  break;Executed by: 
 | 4246 | ||||||||||||
| 210 | - | |||||||||||||
| 211 | case ASN1_ITYPE_SEQUENCE: executed 16219 times by 1 test:  case 0x1:Executed by: 
 | 16219 | ||||||||||||
| 212 | case ASN1_ITYPE_NDEF_SEQUENCE: executed 880 times by 1 test:  case 0x6:Executed by: 
 | 880 | ||||||||||||
| 213 | if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) 
 
 | 0-11384 | ||||||||||||
| 214 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 215 | if (fname || sname) { 
 
 | 2074-13458 | ||||||||||||
| 216 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { 
 | 5-5710 | ||||||||||||
| 217 | if (BIO_puts(out, " {\n") <= 0) 
 | 0-5710 | ||||||||||||
| 218 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 219 | } else { executed 5710 times by 1 test:  end of blockExecuted by: 
 | 5710 | ||||||||||||
| 220 | if (BIO_puts(out, "\n") <= 0) 
 | 0-5 | ||||||||||||
| 221 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 222 | } executed 5 times by 1 test:  end of blockExecuted by: 
 | 5 | ||||||||||||
| 223 | } | - | ||||||||||||
| 224 | - | |||||||||||||
| 225 | if (asn1_cb) { 
 | 1960-15139 | ||||||||||||
| 226 | i = asn1_cb(ASN1_OP_PRINT_PRE, fld, it, &parg); | - | ||||||||||||
| 227 | if (i == 0) 
 | 0-1960 | ||||||||||||
| 228 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 229 | if (i == 2) 
 | 0-1960 | ||||||||||||
| 230 | return 1; never executed:  return 1; | 0 | ||||||||||||
| 231 | } executed 1960 times by 1 test:  end of blockExecuted by: 
 | 1960 | ||||||||||||
| 232 | - | |||||||||||||
| 233 | /* Print each field entry */ | - | ||||||||||||
| 234 | for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { 
 | 16205-47984 | ||||||||||||
| 235 | const ASN1_TEMPLATE *seqtt; | - | ||||||||||||
| 236 | seqtt = asn1_do_adb(fld, tt, 1); | - | ||||||||||||
| 237 | if (!seqtt) 
 | 0-47984 | ||||||||||||
| 238 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 239 | tmpfld = asn1_get_field_ptr(fld, seqtt); | - | ||||||||||||
| 240 | if (!asn1_template_print_ctx(out, tmpfld, 
 | 894-47090 | ||||||||||||
| 241 | indent + 2, seqtt, pctx)) 
 | 894-47090 | ||||||||||||
| 242 | return 0; executed 894 times by 1 test:  return 0;Executed by: 
 | 894 | ||||||||||||
| 243 | } executed 47090 times by 1 test:  end of blockExecuted by: 
 | 47090 | ||||||||||||
| 244 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { 
 | 5-16200 | ||||||||||||
| 245 | if (BIO_printf(out, "%*s}\n", indent, "") < 0) 
 | 0-16200 | ||||||||||||
| 246 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 247 | } executed 16200 times by 1 test:  end of blockExecuted by: 
 | 16200 | ||||||||||||
| 248 | - | |||||||||||||
| 249 | if (asn1_cb) { 
 | 1607-14598 | ||||||||||||
| 250 | i = asn1_cb(ASN1_OP_PRINT_POST, fld, it, &parg); | - | ||||||||||||
| 251 | if (i == 0) 
 | 0-1607 | ||||||||||||
| 252 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 253 | } executed 1607 times by 1 test:  end of blockExecuted by: 
 | 1607 | ||||||||||||
| 254 | break; executed 16205 times by 1 test:  break;Executed by: 
 | 16205 | ||||||||||||
| 255 | - | |||||||||||||
| 256 | default: never executed:  default: | 0 | ||||||||||||
| 257 | BIO_printf(out, "Unprocessed type %d\n", it->itype); | - | ||||||||||||
| 258 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 259 | } | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | return 1; executed 87408 times by 1 test:  return 1;Executed by: 
 | 87408 | ||||||||||||
| 262 | } | - | ||||||||||||
| 263 | - | |||||||||||||
| 264 | static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, | - | ||||||||||||
| 265 | const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx) | - | ||||||||||||
| 266 | { | - | ||||||||||||
| 267 | int i, flags; | - | ||||||||||||
| 268 | const char *sname, *fname; | - | ||||||||||||
| 269 | ASN1_VALUE *tfld; | - | ||||||||||||
| 270 | flags = tt->flags; | - | ||||||||||||
| 271 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME) 
 | 15-54842 | ||||||||||||
| 272 | sname = ASN1_ITEM_ptr(tt->item)->sname; executed 54842 times by 1 test:  sname = (tt->item)->sname;Executed by: 
 | 54842 | ||||||||||||
| 273 | else | - | ||||||||||||
| 274 | sname = NULL; executed 15 times by 1 test:  sname = ((void *)0) ;Executed by: 
 | 15 | ||||||||||||
| 275 | if (pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME) 
 | 0-54857 | ||||||||||||
| 276 | fname = NULL; never executed:  fname = ((void *)0) ; | 0 | ||||||||||||
| 277 | else | - | ||||||||||||
| 278 | fname = tt->field_name; executed 54857 times by 1 test:  fname = tt->field_name;Executed by: 
 | 54857 | ||||||||||||
| 279 | - | |||||||||||||
| 280 | /* | - | ||||||||||||
| 281 | * If field is embedded then fld needs fixing so it is a pointer to | - | ||||||||||||
| 282 | * a pointer to a field. | - | ||||||||||||
| 283 | */ | - | ||||||||||||
| 284 | if (flags & ASN1_TFLG_EMBED) { 
 | 5380-49477 | ||||||||||||
| 285 | tfld = (ASN1_VALUE *)fld; | - | ||||||||||||
| 286 | fld = &tfld; | - | ||||||||||||
| 287 | } executed 5380 times by 1 test:  end of blockExecuted by: 
 | 5380 | ||||||||||||
| 288 | - | |||||||||||||
| 289 | if (flags & ASN1_TFLG_SK_MASK) { 
 | 8584-46273 | ||||||||||||
| 290 | char *tname; | - | ||||||||||||
| 291 | ASN1_VALUE *skitem; | - | ||||||||||||
| 292 | STACK_OF(ASN1_VALUE) *stack; | - | ||||||||||||
| 293 | - | |||||||||||||
| 294 | /* SET OF, SEQUENCE OF */ | - | ||||||||||||
| 295 | if (fname) { 
 | 0-8584 | ||||||||||||
| 296 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SSOF) { 
 | 0-8584 | ||||||||||||
| 297 | if (flags & ASN1_TFLG_SET_OF) 
 | 2049-6535 | ||||||||||||
| 298 | tname = "SET"; executed 2049 times by 1 test:  tname = "SET";Executed by: 
 | 2049 | ||||||||||||
| 299 | else | - | ||||||||||||
| 300 | tname = "SEQUENCE"; executed 6535 times by 1 test:  tname = "SEQUENCE";Executed by: 
 | 6535 | ||||||||||||
| 301 | if (BIO_printf(out, "%*s%s OF %s {\n", 
 | 0-8584 | ||||||||||||
| 302 | indent, "", tname, tt->field_name) <= 0) 
 | 0-8584 | ||||||||||||
| 303 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 304 | } else if (BIO_printf(out, "%*s%s:\n", indent, "", fname) <= 0) executed 8584 times by 1 test:  end of blockExecuted by: 
 
 | 0-8584 | ||||||||||||
| 305 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 306 | } executed 8584 times by 1 test:  end of blockExecuted by: 
 | 8584 | ||||||||||||
| 307 | stack = (STACK_OF(ASN1_VALUE) *)*fld; | - | ||||||||||||
| 308 | for (i = 0; i < sk_ASN1_VALUE_num(stack); i++) { 
 | 8326-38671 | ||||||||||||
| 309 | if ((i > 0) && (BIO_puts(out, "\n") <= 0)) 
 
 | 0-35150 | ||||||||||||
| 310 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 311 | - | |||||||||||||
| 312 | skitem = sk_ASN1_VALUE_value(stack, i); | - | ||||||||||||
| 313 | if (!asn1_item_print_ctx(out, &skitem, indent + 2, 
 | 258-38413 | ||||||||||||
| 314 | ASN1_ITEM_ptr(tt->item), NULL, NULL, 1, 
 | 258-38413 | ||||||||||||
| 315 | pctx)) 
 | 258-38413 | ||||||||||||
| 316 | return 0; executed 258 times by 1 test:  return 0;Executed by: 
 | 258 | ||||||||||||
| 317 | } executed 38413 times by 1 test:  end of blockExecuted by: 
 | 38413 | ||||||||||||
| 318 | if (i == 0 && BIO_printf(out, "%*s<%s>\n", indent + 2, "", 
 
 | 0-5063 | ||||||||||||
| 319 | stack == NULL ? "ABSENT" : "EMPTY") <= 0) 
 | 0-5063 | ||||||||||||
| 320 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 321 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { 
 | 0-8326 | ||||||||||||
| 322 | if (BIO_printf(out, "%*s}\n", indent, "") <= 0) 
 | 0-8326 | ||||||||||||
| 323 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 324 | } executed 8326 times by 1 test:  end of blockExecuted by: 
 | 8326 | ||||||||||||
| 325 | return 1; executed 8326 times by 1 test:  return 1;Executed by: 
 | 8326 | ||||||||||||
| 326 | } | - | ||||||||||||
| 327 | return asn1_item_print_ctx(out, fld, indent, ASN1_ITEM_ptr(tt->item), executed 46273 times by 1 test:  return asn1_item_print_ctx(out, fld, indent, (tt->item), fname, sname, 0, pctx);Executed by: 
 | 46273 | ||||||||||||
| 328 | fname, sname, 0, pctx); executed 46273 times by 1 test:  return asn1_item_print_ctx(out, fld, indent, (tt->item), fname, sname, 0, pctx);Executed by: 
 | 46273 | ||||||||||||
| 329 | } | - | ||||||||||||
| 330 | - | |||||||||||||
| 331 | static int asn1_print_fsname(BIO *out, int indent, | - | ||||||||||||
| 332 | const char *fname, const char *sname, | - | ||||||||||||
| 333 | const ASN1_PCTX *pctx) | - | ||||||||||||
| 334 | { | - | ||||||||||||
| 335 | static const char spaces[] = " "; | - | ||||||||||||
| 336 | static const int nspaces = sizeof(spaces) - 1; | - | ||||||||||||
| 337 | - | |||||||||||||
| 338 | while (indent > nspaces) { 
 | 1017-77464 | ||||||||||||
| 339 | if (BIO_write(out, spaces, nspaces) != nspaces) 
 | 0-1017 | ||||||||||||
| 340 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 341 | indent -= nspaces; | - | ||||||||||||
| 342 | } executed 1017 times by 1 test:  end of blockExecuted by: 
 | 1017 | ||||||||||||
| 343 | if (BIO_write(out, spaces, indent) != indent) 
 | 0-77464 | ||||||||||||
| 344 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 345 | if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) 
 | 0-77464 | ||||||||||||
| 346 | sname = NULL; never executed:  sname = ((void *)0) ; | 0 | ||||||||||||
| 347 | if (pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME) 
 | 0-77464 | ||||||||||||
| 348 | fname = NULL; never executed:  fname = ((void *)0) ; | 0 | ||||||||||||
| 349 | if (!sname && !fname) 
 
 | 15-53623 | ||||||||||||
| 350 | return 1; executed 23826 times by 1 test:  return 1;Executed by: 
 | 23826 | ||||||||||||
| 351 | if (fname) { 
 | 8430-45208 | ||||||||||||
| 352 | if (BIO_puts(out, fname) <= 0) 
 | 0-45208 | ||||||||||||
| 353 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 354 | } executed 45208 times by 1 test:  end of blockExecuted by: 
 | 45208 | ||||||||||||
| 355 | if (sname) { 
 | 15-53623 | ||||||||||||
| 356 | if (fname) { 
 | 8430-45193 | ||||||||||||
| 357 | if (BIO_printf(out, " (%s)", sname) <= 0) 
 | 0-45193 | ||||||||||||
| 358 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 359 | } else { executed 45193 times by 1 test:  end of blockExecuted by: 
 | 45193 | ||||||||||||
| 360 | if (BIO_puts(out, sname) <= 0) 
 | 0-8430 | ||||||||||||
| 361 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 362 | } executed 8430 times by 1 test:  end of blockExecuted by: 
 | 8430 | ||||||||||||
| 363 | } | - | ||||||||||||
| 364 | if (BIO_write(out, ": ", 2) != 2) 
 | 0-53638 | ||||||||||||
| 365 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 366 | return 1; executed 53638 times by 1 test:  return 1;Executed by: 
 | 53638 | ||||||||||||
| 367 | } | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | static int asn1_print_boolean(BIO *out, int boolval) | - | ||||||||||||
| 370 | { | - | ||||||||||||
| 371 | const char *str; | - | ||||||||||||
| 372 | switch (boolval) { | - | ||||||||||||
| 373 | case -1: executed 1062 times by 1 test:  case -1:Executed by: 
 | 1062 | ||||||||||||
| 374 | str = "BOOL ABSENT"; | - | ||||||||||||
| 375 | break; executed 1062 times by 1 test:  break;Executed by: 
 | 1062 | ||||||||||||
| 376 | - | |||||||||||||
| 377 | case 0: executed 566 times by 1 test:  case 0:Executed by: 
 | 566 | ||||||||||||
| 378 | str = "FALSE"; | - | ||||||||||||
| 379 | break; executed 566 times by 1 test:  break;Executed by: 
 | 566 | ||||||||||||
| 380 | - | |||||||||||||
| 381 | default: executed 1063 times by 1 test:  default:Executed by: 
 | 1063 | ||||||||||||
| 382 | str = "TRUE"; | - | ||||||||||||
| 383 | break; executed 1063 times by 1 test:  break;Executed by: 
 | 1063 | ||||||||||||
| 384 | - | |||||||||||||
| 385 | } | - | ||||||||||||
| 386 | - | |||||||||||||
| 387 | if (BIO_puts(out, str) <= 0) 
 | 0-2691 | ||||||||||||
| 388 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 389 | return 1; executed 2691 times by 1 test:  return 1;Executed by: 
 | 2691 | ||||||||||||
| 390 | - | |||||||||||||
| 391 | } | - | ||||||||||||
| 392 | - | |||||||||||||
| 393 | static int asn1_print_integer(BIO *out, const ASN1_INTEGER *str) | - | ||||||||||||
| 394 | { | - | ||||||||||||
| 395 | char *s; | - | ||||||||||||
| 396 | int ret = 1; | - | ||||||||||||
| 397 | s = i2s_ASN1_INTEGER(NULL, str); | - | ||||||||||||
| 398 | if (s == NULL) 
 | 38-7608 | ||||||||||||
| 399 | return 0; executed 38 times by 1 test:  return 0;Executed by: 
 | 38 | ||||||||||||
| 400 | if (BIO_puts(out, s) <= 0) 
 | 0-7608 | ||||||||||||
| 401 | ret = 0; never executed:  ret = 0; | 0 | ||||||||||||
| 402 | OPENSSL_free(s); | - | ||||||||||||
| 403 | return ret; executed 7608 times by 1 test:  return ret;Executed by: 
 | 7608 | ||||||||||||
| 404 | } | - | ||||||||||||
| 405 | - | |||||||||||||
| 406 | static int asn1_print_oid(BIO *out, const ASN1_OBJECT *oid) | - | ||||||||||||
| 407 | { | - | ||||||||||||
| 408 | char objbuf[80]; | - | ||||||||||||
| 409 | const char *ln; | - | ||||||||||||
| 410 | ln = OBJ_nid2ln(OBJ_obj2nid(oid)); | - | ||||||||||||
| 411 | if (!ln) 
 | 0-8946 | ||||||||||||
| 412 | ln = ""; never executed:  ln = ""; | 0 | ||||||||||||
| 413 | OBJ_obj2txt(objbuf, sizeof(objbuf), oid, 1); | - | ||||||||||||
| 414 | if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0) 
 | 0-8946 | ||||||||||||
| 415 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 416 | return 1; executed 8946 times by 1 test:  return 1;Executed by: 
 | 8946 | ||||||||||||
| 417 | } | - | ||||||||||||
| 418 | - | |||||||||||||
| 419 | static int asn1_print_obstring(BIO *out, const ASN1_STRING *str, int indent) | - | ||||||||||||
| 420 | { | - | ||||||||||||
| 421 | if (str->type == V_ASN1_BIT_STRING) { 
 | 1715-4230 | ||||||||||||
| 422 | if (BIO_printf(out, " (%ld unused bits)\n", str->flags & 0x7) <= 0) 
 | 0-1715 | ||||||||||||
| 423 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 424 | } else if (BIO_puts(out, "\n") <= 0) executed 1715 times by 1 test:  end of blockExecuted by: 
 
 | 0-4230 | ||||||||||||
| 425 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 426 | if ((str->length > 0) 
 | 1529-4416 | ||||||||||||
| 427 | && BIO_dump_indent(out, (const char *)str->data, str->length, 
 | 0-4416 | ||||||||||||
| 428 | indent + 2) <= 0) 
 | 0-4416 | ||||||||||||
| 429 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 430 | return 1; executed 5945 times by 1 test:  return 1;Executed by: 
 | 5945 | ||||||||||||
| 431 | } | - | ||||||||||||
| 432 | - | |||||||||||||
| 433 | static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld, | - | ||||||||||||
| 434 | const ASN1_ITEM *it, int indent, | - | ||||||||||||
| 435 | const char *fname, const char *sname, | - | ||||||||||||
| 436 | const ASN1_PCTX *pctx) | - | ||||||||||||
| 437 | { | - | ||||||||||||
| 438 | long utype; | - | ||||||||||||
| 439 | ASN1_STRING *str; | - | ||||||||||||
| 440 | int ret = 1, needlf = 1; | - | ||||||||||||
| 441 | const char *pname; | - | ||||||||||||
| 442 | const ASN1_PRIMITIVE_FUNCS *pf; | - | ||||||||||||
| 443 | pf = it->funcs; | - | ||||||||||||
| 444 | if (!asn1_print_fsname(out, indent, fname, sname, pctx)) 
 | 0-65741 | ||||||||||||
| 445 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 446 | if (pf && pf->prim_print) 
 
 | 0-53477 | ||||||||||||
| 447 | return pf->prim_print(out, fld, it, indent, pctx); executed 12264 times by 1 test:  return pf->prim_print(out, fld, it, indent, pctx);Executed by: 
 | 12264 | ||||||||||||
| 448 | if (it->itype == ASN1_ITYPE_MSTRING) { 
 | 3871-49606 | ||||||||||||
| 449 | str = (ASN1_STRING *)*fld; | - | ||||||||||||
| 450 | utype = str->type & ~V_ASN1_NEG; | - | ||||||||||||
| 451 | } else { executed 3871 times by 1 test:  end of blockExecuted by: 
 | 3871 | ||||||||||||
| 452 | utype = it->utype; | - | ||||||||||||
| 453 | if (utype == V_ASN1_BOOLEAN) 
 | 2434-47172 | ||||||||||||
| 454 | str = NULL; executed 2434 times by 1 test:  str = ((void *)0) ;Executed by: 
 | 2434 | ||||||||||||
| 455 | else | - | ||||||||||||
| 456 | str = (ASN1_STRING *)*fld; executed 47172 times by 1 test:  str = (ASN1_STRING *)*fld;Executed by: 
 | 47172 | ||||||||||||
| 457 | } | - | ||||||||||||
| 458 | if (utype == V_ASN1_ANY) { 
 | 25183-28294 | ||||||||||||
| 459 | ASN1_TYPE *atype = (ASN1_TYPE *)*fld; | - | ||||||||||||
| 460 | utype = atype->type; | - | ||||||||||||
| 461 | fld = &atype->value.asn1_value; | - | ||||||||||||
| 462 | str = (ASN1_STRING *)*fld; | - | ||||||||||||
| 463 | if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE) 
 | 0-28294 | ||||||||||||
| 464 | pname = NULL; never executed:  pname = ((void *)0) ; | 0 | ||||||||||||
| 465 | else | - | ||||||||||||
| 466 | pname = ASN1_tag2str(utype); executed 28294 times by 1 test:  pname = ASN1_tag2str(utype);Executed by: 
 | 28294 | ||||||||||||
| 467 | } else { | - | ||||||||||||
| 468 | if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_TYPE) 
 | 5-25178 | ||||||||||||
| 469 | pname = ASN1_tag2str(utype); executed 25178 times by 1 test:  pname = ASN1_tag2str(utype);Executed by: 
 | 25178 | ||||||||||||
| 470 | else | - | ||||||||||||
| 471 | pname = NULL; executed 5 times by 1 test:  pname = ((void *)0) ;Executed by: 
 | 5 | ||||||||||||
| 472 | } | - | ||||||||||||
| 473 | - | |||||||||||||
| 474 | if (utype == V_ASN1_NULL) { 
 | 1694-51783 | ||||||||||||
| 475 | if (BIO_puts(out, "NULL\n") <= 0) 
 | 0-1694 | ||||||||||||
| 476 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 477 | return 1; executed 1694 times by 1 test:  return 1;Executed by: 
 | 1694 | ||||||||||||
| 478 | } | - | ||||||||||||
| 479 | - | |||||||||||||
| 480 | if (pname) { 
 | 5-51778 | ||||||||||||
| 481 | if (BIO_puts(out, pname) <= 0) 
 | 0-51778 | ||||||||||||
| 482 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 483 | if (BIO_puts(out, ":") <= 0) 
 | 0-51778 | ||||||||||||
| 484 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 485 | } executed 51778 times by 1 test:  end of blockExecuted by: 
 | 51778 | ||||||||||||
| 486 | - | |||||||||||||
| 487 | switch (utype) { | - | ||||||||||||
| 488 | case V_ASN1_BOOLEAN: executed 2691 times by 1 test:  case 1:Executed by: 
 | 2691 | ||||||||||||
| 489 | { | - | ||||||||||||
| 490 | int boolval = *(int *)fld; | - | ||||||||||||
| 491 | if (boolval == -1) 
 | 1062-1629 | ||||||||||||
| 492 | boolval = it->size; executed 1062 times by 1 test:  boolval = it->size;Executed by: 
 | 1062 | ||||||||||||
| 493 | ret = asn1_print_boolean(out, boolval); | - | ||||||||||||
| 494 | } | - | ||||||||||||
| 495 | break; executed 2691 times by 1 test:  break;Executed by: 
 | 2691 | ||||||||||||
| 496 | - | |||||||||||||
| 497 | case V_ASN1_INTEGER: executed 7608 times by 1 test:  case 2:Executed by: 
 | 7608 | ||||||||||||
| 498 | case V_ASN1_ENUMERATED: executed 38 times by 1 test:  case 10:Executed by: 
 | 38 | ||||||||||||
| 499 | ret = asn1_print_integer(out, str); | - | ||||||||||||
| 500 | break; executed 7646 times by 1 test:  break;Executed by: 
 | 7646 | ||||||||||||
| 501 | - | |||||||||||||
| 502 | case V_ASN1_UTCTIME: executed 1949 times by 1 test:  case 23:Executed by: 
 | 1949 | ||||||||||||
| 503 | ret = ASN1_UTCTIME_print(out, str); | - | ||||||||||||
| 504 | break; executed 1949 times by 1 test:  break;Executed by: 
 | 1949 | ||||||||||||
| 505 | - | |||||||||||||
| 506 | case V_ASN1_GENERALIZEDTIME: executed 1304 times by 1 test:  case 24:Executed by: 
 | 1304 | ||||||||||||
| 507 | ret = ASN1_GENERALIZEDTIME_print(out, str); | - | ||||||||||||
| 508 | break; executed 1304 times by 1 test:  break;Executed by: 
 | 1304 | ||||||||||||
| 509 | - | |||||||||||||
| 510 | case V_ASN1_OBJECT: executed 8946 times by 1 test:  case 6:Executed by: 
 | 8946 | ||||||||||||
| 511 | ret = asn1_print_oid(out, (const ASN1_OBJECT *)*fld); | - | ||||||||||||
| 512 | break; executed 8946 times by 1 test:  break;Executed by: 
 | 8946 | ||||||||||||
| 513 | - | |||||||||||||
| 514 | case V_ASN1_OCTET_STRING: executed 4230 times by 1 test:  case 4:Executed by: 
 | 4230 | ||||||||||||
| 515 | case V_ASN1_BIT_STRING: executed 1715 times by 1 test:  case 3:Executed by: 
 | 1715 | ||||||||||||
| 516 | ret = asn1_print_obstring(out, str, indent); | - | ||||||||||||
| 517 | needlf = 0; | - | ||||||||||||
| 518 | break; executed 5945 times by 1 test:  break;Executed by: 
 | 5945 | ||||||||||||
| 519 | - | |||||||||||||
| 520 | case V_ASN1_SEQUENCE: executed 11569 times by 1 test:  case 16:Executed by: 
 | 11569 | ||||||||||||
| 521 | case V_ASN1_SET: executed 764 times by 1 test:  case 17:Executed by: 
 | 764 | ||||||||||||
| 522 | case V_ASN1_OTHER: executed 7955 times by 1 test:  case -3:Executed by: 
 | 7955 | ||||||||||||
| 523 | if (BIO_puts(out, "\n") <= 0) 
 | 0-20288 | ||||||||||||
| 524 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 525 | if (ASN1_parse_dump(out, str->data, str->length, indent, 0) <= 0) 
 | 830-19458 | ||||||||||||
| 526 | ret = 0; executed 830 times by 1 test:  ret = 0;Executed by: 
 | 830 | ||||||||||||
| 527 | needlf = 0; | - | ||||||||||||
| 528 | break; executed 20288 times by 1 test:  break;Executed by: 
 | 20288 | ||||||||||||
| 529 | - | |||||||||||||
| 530 | default: executed 3014 times by 1 test:  default:Executed by: 
 | 3014 | ||||||||||||
| 531 | ret = ASN1_STRING_print_ex(out, str, pctx->str_flags); | - | ||||||||||||
| 532 | - | |||||||||||||
| 533 | } executed 3014 times by 1 test:  end of blockExecuted by: 
 | 3014 | ||||||||||||
| 534 | if (!ret) 
 | 1211-50572 | ||||||||||||
| 535 | return 0; executed 1211 times by 1 test:  return 0;Executed by: 
 | 1211 | ||||||||||||
| 536 | if (needlf && BIO_puts(out, "\n") <= 0) 
 
 | 0-25403 | ||||||||||||
| 537 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 538 | return 1; executed 50572 times by 1 test:  return 1;Executed by: 
 | 50572 | ||||||||||||
| 539 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |