OpenCoverage

v3_prn.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509v3/v3_prn.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1999-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/* X509 v3 extension utilities */-
11-
12#include <stdio.h>-
13#include "internal/cryptlib.h"-
14#include <openssl/conf.h>-
15#include <openssl/x509v3.h>-
16-
17/* Extension printing routines */-
18-
19static int unknown_ext_print(BIO *out, const unsigned char *ext, int extlen,-
20 unsigned long flag, int indent, int supported);-
21-
22/* Print out a name+value stack */-
23-
24void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,-
25 int ml)-
26{-
27 int i;-
28 CONF_VALUE *nval;-
29 if (!val)
!valDescription
TRUEnever evaluated
FALSEevaluated 8662 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8662
30 return;
never executed: return;
0
31 if (!ml || !sk_CONF_VALUE_num(val)) {
!mlDescription
TRUEevaluated 6261 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2401 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!sk_CONF_VALUE_num(val)Description
TRUEevaluated 562 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1839 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
562-6261
32 BIO_printf(out, "%*s", indent, "");-
33 if (!sk_CONF_VALUE_num(val))
!sk_CONF_VALUE_num(val)Description
TRUEevaluated 624 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6199 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
624-6199
34 BIO_puts(out, "<EMPTY>\n");
executed 624 times by 1 test: BIO_puts(out, "<EMPTY>\n");
Executed by:
  • libcrypto.so.1.1
624
35 }
executed 6823 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6823
36 for (i = 0; i < sk_CONF_VALUE_num(val); i++) {
i < sk_CONF_VALUE_num(val)Description
TRUEevaluated 16157 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8662 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8662-16157
37 if (ml)
mlDescription
TRUEevaluated 2441 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 13716 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2441-13716
38 BIO_printf(out, "%*s", indent, "");
executed 2441 times by 1 test: BIO_printf(out, "%*s", indent, "");
Executed by:
  • libcrypto.so.1.1
2441
39 else if (i > 0)
i > 0Description
TRUEevaluated 7517 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6199 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
6199-7517
40 BIO_printf(out, ", ");
executed 7517 times by 1 test: BIO_printf(out, ", ");
Executed by:
  • libcrypto.so.1.1
7517
41 nval = sk_CONF_VALUE_value(val, i);-
42 if (!nval->name)
!nval->nameDescription
TRUEevaluated 2367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 13790 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2367-13790
43 BIO_puts(out, nval->value);
executed 2367 times by 1 test: BIO_puts(out, nval->value);
Executed by:
  • libcrypto.so.1.1
2367
44 else if (!nval->value)
!nval->valueDescription
TRUEevaluated 3247 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10543 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3247-10543
45 BIO_puts(out, nval->name);
executed 3247 times by 1 test: BIO_puts(out, nval->name);
Executed by:
  • libcrypto.so.1.1
3247
46#ifndef CHARSET_EBCDIC-
47 else-
48 BIO_printf(out, "%s:%s", nval->name, nval->value);
executed 10543 times by 1 test: BIO_printf(out, "%s:%s", nval->name, nval->value);
Executed by:
  • libcrypto.so.1.1
10543
49#else-
50 else {-
51 int len;-
52 char *tmp;-
53 len = strlen(nval->value) + 1;-
54 tmp = OPENSSL_malloc(len);-
55 if (tmp != NULL) {-
56 ascii2ebcdic(tmp, nval->value, len);-
57 BIO_printf(out, "%s:%s", nval->name, tmp);-
58 OPENSSL_free(tmp);-
59 }-
60 }-
61#endif-
62 if (ml)
mlDescription
TRUEevaluated 2441 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 13716 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2441-13716
63 BIO_puts(out, "\n");
executed 2441 times by 1 test: BIO_puts(out, "\n");
Executed by:
  • libcrypto.so.1.1
2441
64 }
executed 16157 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
16157
65}
executed 8662 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
8662
66-
67/* Main routine: print out a general extension */-
68-
69int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,-
70 int indent)-
71{-
72 void *ext_str = NULL;-
73 char *value = NULL;-
74 ASN1_OCTET_STRING *extoct;-
75 const unsigned char *p;-
76 int extlen;-
77 const X509V3_EXT_METHOD *method;-
78 STACK_OF(CONF_VALUE) *nval = NULL;-
79 int ok = 1;-
80-
81 extoct = X509_EXTENSION_get_data(ext);-
82 p = ASN1_STRING_get0_data(extoct);-
83 extlen = ASN1_STRING_length(extoct);-
84-
85 if ((method = X509V3_EXT_get(ext)) == NULL)
(method = X509...== ((void *)0)Description
TRUEevaluated 13699 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 85245 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
13699-85245
86 return unknown_ext_print(out, p, extlen, flag, indent, 0);
executed 13699 times by 1 test: return unknown_ext_print(out, p, extlen, flag, indent, 0);
Executed by:
  • libcrypto.so.1.1
13699
87 if (method->it)
method->itDescription
TRUEevaluated 78012 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7233 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7233-78012
88 ext_str = ASN1_item_d2i(NULL, &p, extlen, ASN1_ITEM_ptr(method->it));
executed 78012 times by 1 test: ext_str = ASN1_item_d2i( ((void *)0) , &p, extlen, (method->it));
Executed by:
  • libcrypto.so.1.1
78012
89 else-
90 ext_str = method->d2i(NULL, &p, extlen);
executed 7233 times by 1 test: ext_str = method->d2i( ((void *)0) , &p, extlen);
Executed by:
  • libcrypto.so.1.1
7233
91-
92 if (!ext_str)
!ext_strDescription
TRUEevaluated 38372 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 46873 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
38372-46873
93 return unknown_ext_print(out, p, extlen, flag, indent, 1);
executed 38372 times by 1 test: return unknown_ext_print(out, p, extlen, flag, indent, 1);
Executed by:
  • libcrypto.so.1.1
38372
94-
95 if (method->i2s) {
method->i2sDescription
TRUEevaluated 4536 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 42337 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4536-42337
96 if ((value = method->i2s(method, ext_str)) == NULL) {
(value = metho...== ((void *)0)Description
TRUEevaluated 388 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4148 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
388-4148
97 ok = 0;-
98 goto err;
executed 388 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
388
99 }-
100#ifndef CHARSET_EBCDIC-
101 BIO_printf(out, "%*s%s", indent, "", value);-
102#else-
103 {-
104 int len;-
105 char *tmp;-
106 len = strlen(value) + 1;-
107 tmp = OPENSSL_malloc(len);-
108 if (tmp != NULL) {-
109 ascii2ebcdic(tmp, value, len);-
110 BIO_printf(out, "%*s%s", indent, "", tmp);-
111 OPENSSL_free(tmp);-
112 }-
113 }-
114#endif-
115 } else if (method->i2v) {
executed 4148 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
method->i2vDescription
TRUEevaluated 10715 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 31622 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4148-31622
116 if ((nval = method->i2v(method, ext_str, NULL)) == NULL) {
(nval = method...== ((void *)0)Description
TRUEevaluated 2053 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8662 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2053-8662
117 ok = 0;-
118 goto err;
executed 2053 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
2053
119 }-
120 X509V3_EXT_val_prn(out, nval, indent,-
121 method->ext_flags & X509V3_EXT_MULTILINE);-
122 } else if (method->i2r) {
executed 8662 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
method->i2rDescription
TRUEevaluated 31622 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-31622
123 if (!method->i2r(method, ext_str, out, indent))
!method->i2r(m..., out, indent)Description
TRUEevaluated 5762 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 25860 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5762-25860
124 ok = 0;
executed 5762 times by 1 test: ok = 0;
Executed by:
  • libcrypto.so.1.1
5762
125 } else
executed 31622 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
31622
126 ok = 0;
never executed: ok = 0;
0
127-
128 err:
code before this statement executed 44432 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
44432
129 sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);-
130 OPENSSL_free(value);-
131 if (method->it)
method->itDescription
TRUEevaluated 43268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3605 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3605-43268
132 ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it));
executed 43268 times by 1 test: ASN1_item_free(ext_str, (method->it));
Executed by:
  • libcrypto.so.1.1
43268
133 else-
134 method->ext_free(ext_str);
executed 3605 times by 1 test: method->ext_free(ext_str);
Executed by:
  • libcrypto.so.1.1
3605
135 return ok;
executed 46873 times by 1 test: return ok;
Executed by:
  • libcrypto.so.1.1
46873
136}-
137-
138int X509V3_extensions_print(BIO *bp, const char *title,-
139 const STACK_OF(X509_EXTENSION) *exts,-
140 unsigned long flag, int indent)-
141{-
142 int i, j;-
143-
144 if (sk_X509_EXTENSION_num(exts) <= 0)
sk_X509_EXTENS...num(exts) <= 0Description
TRUEevaluated 7323 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4338 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4338-7323
145 return 1;
executed 7323 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
7323
146-
147 if (title) {
titleDescription
TRUEevaluated 4338 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4338
148 BIO_printf(bp, "%*s%s:\n", indent, "", title);-
149 indent += 4;-
150 }
executed 4338 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4338
151-
152 for (i = 0; i < sk_X509_EXTENSION_num(exts); i++) {
i < sk_X509_EX...SION_num(exts)Description
TRUEevaluated 82948 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4338 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4338-82948
153 ASN1_OBJECT *obj;-
154 X509_EXTENSION *ex;-
155 ex = sk_X509_EXTENSION_value(exts, i);-
156 if (indent && BIO_printf(bp, "%*s", indent, "") <= 0)
indentDescription
TRUEevaluated 82948 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
BIO_printf(bp,...dent, "") <= 0Description
TRUEnever evaluated
FALSEevaluated 82948 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-82948
157 return 0;
never executed: return 0;
0
158 obj = X509_EXTENSION_get_object(ex);-
159 i2a_ASN1_OBJECT(bp, obj);-
160 j = X509_EXTENSION_get_critical(ex);-
161 if (BIO_printf(bp, ": %s\n", j ? "critical" : "") <= 0)
BIO_printf(bp,...al" : "") <= 0Description
TRUEnever evaluated
FALSEevaluated 82948 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-82948
162 return 0;
never executed: return 0;
0
163 if (!X509V3_EXT_print(bp, ex, flag, indent + 4)) {
!X509V3_EXT_pr...g, indent + 4)Description
TRUEevaluated 54573 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 28375 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
28375-54573
164 BIO_printf(bp, "%*s", indent + 4, "");-
165 ASN1_STRING_print(bp, X509_EXTENSION_get_data(ex));-
166 }
executed 54573 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
54573
167 if (BIO_write(bp, "\n", 1) <= 0)
BIO_write(bp, "\n", 1) <= 0Description
TRUEnever evaluated
FALSEevaluated 82948 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-82948
168 return 0;
never executed: return 0;
0
169 }
executed 82948 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
82948
170 return 1;
executed 4338 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
4338
171}-
172-
173static int unknown_ext_print(BIO *out, const unsigned char *ext, int extlen,-
174 unsigned long flag, int indent, int supported)-
175{-
176 switch (flag & X509V3_EXT_UNKNOWN_MASK) {-
177-
178 case X509V3_EXT_DEFAULT:
executed 52071 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
52071
179 return 0;
executed 52071 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
52071
180-
181 case X509V3_EXT_ERROR_UNKNOWN:
never executed: case (1L << 16):
0
182 if (supported)
supportedDescription
TRUEnever evaluated
FALSEnever evaluated
0
183 BIO_printf(out, "%*s<Parse Error>", indent, "");
never executed: BIO_printf(out, "%*s<Parse Error>", indent, "");
0
184 else-
185 BIO_printf(out, "%*s<Not Supported>", indent, "");
never executed: BIO_printf(out, "%*s<Not Supported>", indent, "");
0
186 return 1;
never executed: return 1;
0
187-
188 case X509V3_EXT_PARSE_UNKNOWN:
never executed: case (2L << 16):
0
189 return ASN1_parse_dump(out, ext, extlen, indent, -1);
never executed: return ASN1_parse_dump(out, ext, extlen, indent, -1);
0
190 case X509V3_EXT_DUMP_UNKNOWN:
never executed: case (3L << 16):
0
191 return BIO_dump_indent(out, (const char *)ext, extlen, indent);
never executed: return BIO_dump_indent(out, (const char *)ext, extlen, indent);
0
192-
193 default:
never executed: default:
0
194 return 1;
never executed: return 1;
0
195 }-
196}-
197-
198#ifndef OPENSSL_NO_STDIO-
199int X509V3_EXT_print_fp(FILE *fp, X509_EXTENSION *ext, int flag, int indent)-
200{-
201 BIO *bio_tmp;-
202 int ret;-
203-
204 if ((bio_tmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL)
(bio_tmp = BIO...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
205 return 0;
never executed: return 0;
0
206 ret = X509V3_EXT_print(bio_tmp, ext, flag, indent);-
207 BIO_free(bio_tmp);-
208 return ret;
never executed: return ret;
0
209}-
210#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2