diff options
| author | tb <> | 2023-12-20 14:26:47 +0000 |
|---|---|---|
| committer | tb <> | 2023-12-20 14:26:47 +0000 |
| commit | 3bf9c20f1fb1972d6bcd3c03926a791a2ab6e226 (patch) | |
| tree | 700436ca99f9deb9e2683d53f3956538ea1f93b4 /src | |
| parent | f001ba54bff12dd17cc60c6ba9757b0f9e8c3daa (diff) | |
| download | openbsd-3bf9c20f1fb1972d6bcd3c03926a791a2ab6e226.tar.gz openbsd-3bf9c20f1fb1972d6bcd3c03926a791a2ab6e226.tar.bz2 openbsd-3bf9c20f1fb1972d6bcd3c03926a791a2ab6e226.zip | |
Use BIO_indent() for indentation in tasn_prn.c
Using a loop to print pieces of a static buffer containing 20 spaces to
indent things is just silly. Even sillier is making this buffer const
without looking what it's actually used for... There is BIO_indent() or
BIO_printf() that can handle "%*s".
Add a length check to preserve behavior since BIO_indent() succeeds for
negattive indent.
However, peak silliness must be how BIO_dump_indent_cb() indents things.
That's for another day.
ok jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/tasn_prn.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c index 3f61a689d0..d404838c68 100644 --- a/src/lib/libcrypto/asn1/tasn_prn.c +++ b/src/lib/libcrypto/asn1/tasn_prn.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tasn_prn.c,v 1.25 2023/07/05 21:23:36 beck Exp $ */ | 1 | /* $OpenBSD: tasn_prn.c,v 1.26 2023/12/20 14:26:47 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -395,15 +395,9 @@ static int | |||
| 395 | asn1_print_fsname(BIO *out, int indent, const char *fname, const char *sname, | 395 | asn1_print_fsname(BIO *out, int indent, const char *fname, const char *sname, |
| 396 | const ASN1_PCTX *pctx) | 396 | const ASN1_PCTX *pctx) |
| 397 | { | 397 | { |
| 398 | static char spaces[] = " "; | 398 | if (indent < 0) |
| 399 | const int nspaces = sizeof(spaces) - 1; | 399 | return 0; |
| 400 | 400 | if (!BIO_indent(out, indent, indent)) | |
| 401 | while (indent > nspaces) { | ||
| 402 | if (BIO_write(out, spaces, nspaces) != nspaces) | ||
| 403 | return 0; | ||
| 404 | indent -= nspaces; | ||
| 405 | } | ||
| 406 | if (BIO_write(out, spaces, indent) != indent) | ||
| 407 | return 0; | 401 | return 0; |
| 408 | if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) | 402 | if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) |
| 409 | sname = NULL; | 403 | sname = NULL; |
