diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bio/b_dump.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c index e46424e699..ef965b61d0 100644 --- a/src/lib/libcrypto/bio/b_dump.c +++ b/src/lib/libcrypto/bio/b_dump.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: b_dump.c,v 1.26 2023/07/29 02:32:00 tb Exp $ */ | 1 | /* $OpenBSD: b_dump.c,v 1.27 2024/02/01 17:04:09 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 | * |
| @@ -64,21 +64,14 @@ | |||
| 64 | #include <string.h> | 64 | #include <string.h> |
| 65 | 65 | ||
| 66 | #include <openssl/bio.h> | 66 | #include <openssl/bio.h> |
| 67 | #include <openssl/err.h> | ||
| 67 | 68 | ||
| 68 | #define TRUNCATE | 69 | #define TRUNCATE |
| 69 | #define DUMP_WIDTH 16 | 70 | #define DUMP_WIDTH 16 |
| 70 | #define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH - ((i - (i > 6 ? 6 : i) + 3) / 4)) | 71 | #define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH - ((i - (i > 6 ? 6 : i) + 3) / 4)) |
| 71 | 72 | ||
| 72 | int | 73 | int |
| 73 | BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), | 74 | BIO_dump_indent(BIO *bio, const char *s, int len, int indent) |
| 74 | void *u, const char *s, int len) | ||
| 75 | { | ||
| 76 | return BIO_dump_indent_cb(cb, u, s, len, 0); | ||
| 77 | } | ||
| 78 | |||
| 79 | int | ||
| 80 | BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | ||
| 81 | void *u, const char *s, int len, int indent) | ||
| 82 | { | 75 | { |
| 83 | char buf[288 + 1], tmp[20], str[128 + 1]; | 76 | char buf[288 + 1], tmp[20], str[128 + 1]; |
| 84 | int i, j, rows, trc, written; | 77 | int i, j, rows, trc, written; |
| @@ -132,7 +125,7 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | |||
| 132 | /* if this is the last call then update the ddt_dump thing so | 125 | /* if this is the last call then update the ddt_dump thing so |
| 133 | * that we will move the selection point in the debug window | 126 | * that we will move the selection point in the debug window |
| 134 | */ | 127 | */ |
| 135 | if ((written = cb((void *)buf, strlen(buf), u)) < 0) | 128 | if ((written = BIO_write(bio, buf, strlen(buf))) < 0) |
| 136 | return -1; | 129 | return -1; |
| 137 | ret += written; | 130 | ret += written; |
| 138 | 131 | ||
| @@ -141,50 +134,54 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | |||
| 141 | if (trc > 0) { | 134 | if (trc > 0) { |
| 142 | snprintf(buf, sizeof buf, "%s%04x - <SPACES/NULS>\n", | 135 | snprintf(buf, sizeof buf, "%s%04x - <SPACES/NULS>\n", |
| 143 | str, len + trc); | 136 | str, len + trc); |
| 144 | if ((written = cb((void *)buf, strlen(buf), u)) < 0) | 137 | if ((written = BIO_write(bio, buf, strlen(buf))) < 0) |
| 145 | return -1; | 138 | return -1; |
| 146 | ret += written; | 139 | ret += written; |
| 147 | } | 140 | } |
| 148 | #endif | 141 | #endif |
| 149 | return (ret); | 142 | return (ret); |
| 150 | } | 143 | } |
| 151 | 144 | LCRYPTO_ALIAS(BIO_dump_indent); | |
| 152 | static int | ||
| 153 | write_fp(const void *data, size_t len, void *fp) | ||
| 154 | { | ||
| 155 | return fwrite(data, 1, len, fp); | ||
| 156 | } | ||
| 157 | 145 | ||
| 158 | int | 146 | int |
| 159 | BIO_dump_fp(FILE *fp, const char *s, int len) | 147 | BIO_dump(BIO *bio, const char *s, int len) |
| 160 | { | 148 | { |
| 161 | return BIO_dump_cb(write_fp, fp, s, len); | 149 | return BIO_dump_indent(bio, s, len, 0); |
| 162 | } | 150 | } |
| 163 | LCRYPTO_ALIAS(BIO_dump_fp); | 151 | LCRYPTO_ALIAS(BIO_dump); |
| 152 | |||
| 153 | /* | ||
| 154 | * XXX - remove the functions below in the next major bump. | ||
| 155 | */ | ||
| 164 | 156 | ||
| 165 | int | 157 | int |
| 166 | BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent) | 158 | BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), |
| 159 | void *u, const char *s, int len) | ||
| 167 | { | 160 | { |
| 168 | return BIO_dump_indent_cb(write_fp, fp, s, len, indent); | 161 | BIOerror(ERR_R_DISABLED); |
| 162 | return -1; | ||
| 169 | } | 163 | } |
| 170 | LCRYPTO_ALIAS(BIO_dump_indent_fp); | ||
| 171 | 164 | ||
| 172 | static int | 165 | int |
| 173 | write_bio(const void *data, size_t len, void *bp) | 166 | BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), |
| 167 | void *u, const char *s, int len, int indent) | ||
| 174 | { | 168 | { |
| 175 | return BIO_write((BIO *)bp, (const char *)data, len); | 169 | BIOerror(ERR_R_DISABLED); |
| 170 | return -1; | ||
| 176 | } | 171 | } |
| 177 | 172 | ||
| 178 | int | 173 | int |
| 179 | BIO_dump(BIO *bp, const char *s, int len) | 174 | BIO_dump_fp(FILE *fp, const char *s, int len) |
| 180 | { | 175 | { |
| 181 | return BIO_dump_cb(write_bio, bp, s, len); | 176 | BIOerror(ERR_R_DISABLED); |
| 177 | return -1; | ||
| 182 | } | 178 | } |
| 183 | LCRYPTO_ALIAS(BIO_dump); | 179 | LCRYPTO_ALIAS(BIO_dump_fp); |
| 184 | 180 | ||
| 185 | int | 181 | int |
| 186 | BIO_dump_indent(BIO *bp, const char *s, int len, int indent) | 182 | BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent) |
| 187 | { | 183 | { |
| 188 | return BIO_dump_indent_cb(write_bio, bp, s, len, indent); | 184 | BIOerror(ERR_R_DISABLED); |
| 185 | return -1; | ||
| 189 | } | 186 | } |
| 190 | LCRYPTO_ALIAS(BIO_dump_indent); | 187 | LCRYPTO_ALIAS(BIO_dump_indent_fp); |
