summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2025-06-25 18:28:47 +0000
committertb <>2025-06-25 18:28:47 +0000
commit23fea706f4b9065d3484a98ab6ced1d469d5b35d (patch)
tree9b65af085e5eb01985b0fa950d5cc3161ffcbbad /src
parentcc1564b587827740d58aaecb6c1fb7174458c7f1 (diff)
downloadopenbsd-23fea706f4b9065d3484a98ab6ced1d469d5b35d.tar.gz
openbsd-23fea706f4b9065d3484a98ab6ced1d469d5b35d.tar.bz2
openbsd-23fea706f4b9065d3484a98ab6ced1d469d5b35d.zip
X509_print and friends: switch from BIO_write() to BIO_printf()
Manually counting letters in const strings is ... suboptimal. ok beck jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 417e92bcc5..89a9085249 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t_x509.c,v 1.52 2025/05/10 05:54:38 tb Exp $ */ 1/* $OpenBSD: t_x509.c,v 1.53 2025/06/25 18:28:47 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -127,9 +127,9 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
127 127
128 ci = x->cert_info; 128 ci = x->cert_info;
129 if (!(cflag & X509_FLAG_NO_HEADER)) { 129 if (!(cflag & X509_FLAG_NO_HEADER)) {
130 if (BIO_write(bp, "Certificate:\n", 13) <= 0) 130 if (BIO_printf(bp, "Certificate:\n") <= 0)
131 goto err; 131 goto err;
132 if (BIO_write(bp, " Data:\n", 10) <= 0) 132 if (BIO_printf(bp, " Data:\n") <= 0)
133 goto err; 133 goto err;
134 } 134 }
135 if (!(cflag & X509_FLAG_NO_VERSION)) { 135 if (!(cflag & X509_FLAG_NO_VERSION)) {
@@ -145,7 +145,7 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
145 } 145 }
146 } 146 }
147 if (!(cflag & X509_FLAG_NO_SERIAL)) { 147 if (!(cflag & X509_FLAG_NO_SERIAL)) {
148 if (BIO_write(bp, " Serial Number:", 22) <= 0) 148 if (BIO_printf(bp, " Serial Number:") <= 0)
149 goto err; 149 goto err;
150 150
151 bs = X509_get_serialNumber(x); 151 bs = X509_get_serialNumber(x);
@@ -196,21 +196,21 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
196 if (X509_NAME_print_ex(bp, X509_get_issuer_name(x), 196 if (X509_NAME_print_ex(bp, X509_get_issuer_name(x),
197 nmindent, nmflags) < (nmflags == X509_FLAG_COMPAT ? 1 : 0)) 197 nmindent, nmflags) < (nmflags == X509_FLAG_COMPAT ? 1 : 0))
198 goto err; 198 goto err;
199 if (BIO_write(bp, "\n", 1) <= 0) 199 if (BIO_printf(bp, "\n") <= 0)
200 goto err; 200 goto err;
201 } 201 }
202 if (!(cflag & X509_FLAG_NO_VALIDITY)) { 202 if (!(cflag & X509_FLAG_NO_VALIDITY)) {
203 if (BIO_write(bp, " Validity\n", 17) <= 0) 203 if (BIO_printf(bp, " Validity\n") <= 0)
204 goto err; 204 goto err;
205 if (BIO_write(bp, " Not Before: ", 24) <= 0) 205 if (BIO_printf(bp, " Not Before: ") <= 0)
206 goto err; 206 goto err;
207 if (!ASN1_TIME_print(bp, X509_get_notBefore(x))) 207 if (!ASN1_TIME_print(bp, X509_get_notBefore(x)))
208 goto err; 208 goto err;
209 if (BIO_write(bp, "\n Not After : ", 25) <= 0) 209 if (BIO_printf(bp, "\n Not After : ") <= 0)
210 goto err; 210 goto err;
211 if (!ASN1_TIME_print(bp, X509_get_notAfter(x))) 211 if (!ASN1_TIME_print(bp, X509_get_notAfter(x)))
212 goto err; 212 goto err;
213 if (BIO_write(bp, "\n", 1) <= 0) 213 if (BIO_printf(bp, "\n") <= 0)
214 goto err; 214 goto err;
215 } 215 }
216 if (!(cflag & X509_FLAG_NO_SUBJECT)) { 216 if (!(cflag & X509_FLAG_NO_SUBJECT)) {
@@ -219,12 +219,11 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
219 if (X509_NAME_print_ex(bp, X509_get_subject_name(x), 219 if (X509_NAME_print_ex(bp, X509_get_subject_name(x),
220 nmindent, nmflags) < (nmflags == X509_FLAG_COMPAT ? 1 : 0)) 220 nmindent, nmflags) < (nmflags == X509_FLAG_COMPAT ? 1 : 0))
221 goto err; 221 goto err;
222 if (BIO_write(bp, "\n", 1) <= 0) 222 if (BIO_printf(bp, "\n") <= 0)
223 goto err; 223 goto err;
224 } 224 }
225 if (!(cflag & X509_FLAG_NO_PUBKEY)) { 225 if (!(cflag & X509_FLAG_NO_PUBKEY)) {
226 if (BIO_write(bp, " Subject Public Key Info:\n", 226 if (BIO_printf(bp, " Subject Public Key Info:\n") <= 0)
227 33) <= 0)
228 goto err; 227 goto err;
229 if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) 228 if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0)
230 goto err; 229 goto err;
@@ -325,7 +324,7 @@ X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent)
325 s = sig->data; 324 s = sig->data;
326 for (i = 0; i < n; i++) { 325 for (i = 0; i < n; i++) {
327 if ((i % 18) == 0) { 326 if ((i % 18) == 0) {
328 if (BIO_write(bp, "\n", 1) <= 0) 327 if (BIO_printf(bp, "\n") <= 0)
329 return 0; 328 return 0;
330 if (BIO_indent(bp, indent, indent) <= 0) 329 if (BIO_indent(bp, indent, indent) <= 0)
331 return 0; 330 return 0;
@@ -334,7 +333,7 @@ X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent)
334 ((i + 1) == n) ? "" : ":") <= 0) 333 ((i + 1) == n) ? "" : ":") <= 0)
335 return 0; 334 return 0;
336 } 335 }
337 if (BIO_write(bp, "\n", 1) != 1) 336 if (BIO_printf(bp, "\n") != 1)
338 return 0; 337 return 0;
339 338
340 return 1; 339 return 1;
@@ -375,7 +374,7 @@ ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
375 return ASN1_UTCTIME_print(bp, tm); 374 return ASN1_UTCTIME_print(bp, tm);
376 if (tm->type == V_ASN1_GENERALIZEDTIME) 375 if (tm->type == V_ASN1_GENERALIZEDTIME)
377 return ASN1_GENERALIZEDTIME_print(bp, tm); 376 return ASN1_GENERALIZEDTIME_print(bp, tm);
378 BIO_write(bp, "Bad time value", 14); 377 BIO_printf(bp, "Bad time value");
379 return (0); 378 return (0);
380} 379}
381LCRYPTO_ALIAS(ASN1_TIME_print); 380LCRYPTO_ALIAS(ASN1_TIME_print);
@@ -435,7 +434,7 @@ ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
435 return (1); 434 return (1);
436 435
437 err: 436 err:
438 BIO_write(bp, "Bad time value", 14); 437 BIO_printf(bp, "Bad time value");
439 return (0); 438 return (0);
440} 439}
441LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_print); 440LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_print);
@@ -479,7 +478,7 @@ ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)
479 return (1); 478 return (1);
480 479
481 err: 480 err:
482 BIO_write(bp, "Bad time value", 14); 481 BIO_printf(bp, "Bad time value");
483 return (0); 482 return (0);
484} 483}
485LCRYPTO_ALIAS(ASN1_UTCTIME_print); 484LCRYPTO_ALIAS(ASN1_UTCTIME_print);