diff options
author | beck <> | 2021-07-11 20:18:07 +0000 |
---|---|---|
committer | beck <> | 2021-07-11 20:18:07 +0000 |
commit | 61503dd412d8dc1325b7f7fa2e752b925b1e8b9d (patch) | |
tree | 880e8f5861a3b885764099dac44578629840e2c8 /src/lib/libcrypto/bio/b_dump.c | |
parent | 50cf9b8627997e8f4afdd30db8b001d2a0a24e49 (diff) | |
download | openbsd-61503dd412d8dc1325b7f7fa2e752b925b1e8b9d.tar.gz openbsd-61503dd412d8dc1325b7f7fa2e752b925b1e8b9d.tar.bz2 openbsd-61503dd412d8dc1325b7f7fa2e752b925b1e8b9d.zip |
While the traditional OpenSSL return value and behaviour of BIO_dump(3)
is pure comedy gold, and now documented as such, sadly this bit of pure
Muppet genius can't really in good consience stay in the tree as is.
Change BIO_dump to always return the number of bytes printed on success
and to stop printing and return -1 on failure if a writing function
fails.
ok tb@, jsing@
Diffstat (limited to 'src/lib/libcrypto/bio/b_dump.c')
-rw-r--r-- | src/lib/libcrypto/bio/b_dump.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c index 0214addc8b..7e1c2d7947 100644 --- a/src/lib/libcrypto/bio/b_dump.c +++ b/src/lib/libcrypto/bio/b_dump.c | |||
@@ -1,10 +1,10 @@ | |||
1 | /* $OpenBSD: b_dump.c,v 1.21 2015/04/23 06:11:19 deraadt Exp $ */ | 1 | /* $OpenBSD: b_dump.c,v 1.22 2021/07/11 20:18:07 beck 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 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
@@ -82,7 +82,7 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | |||
82 | { | 82 | { |
83 | int ret = 0; | 83 | int ret = 0; |
84 | char buf[288 + 1], tmp[20], str[128 + 1]; | 84 | char buf[288 + 1], tmp[20], str[128 + 1]; |
85 | int i, j, rows, trc; | 85 | int i, j, rows, trc, written; |
86 | unsigned char ch; | 86 | unsigned char ch; |
87 | int dump_width; | 87 | int dump_width; |
88 | 88 | ||
@@ -133,13 +133,18 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | |||
133 | /* if this is the last call then update the ddt_dump thing so | 133 | /* if this is the last call then update the ddt_dump thing so |
134 | * that we will move the selection point in the debug window | 134 | * that we will move the selection point in the debug window |
135 | */ | 135 | */ |
136 | ret += cb((void *)buf, strlen(buf), u); | 136 | if ((written = cb((void *)buf, strlen(buf), u)) < 0) |
137 | return -1; | ||
138 | ret += written; | ||
139 | |||
137 | } | 140 | } |
138 | #ifdef TRUNCATE | 141 | #ifdef TRUNCATE |
139 | if (trc > 0) { | 142 | if (trc > 0) { |
140 | snprintf(buf, sizeof buf, "%s%04x - <SPACES/NULS>\n", | 143 | snprintf(buf, sizeof buf, "%s%04x - <SPACES/NULS>\n", |
141 | str, len + trc); | 144 | str, len + trc); |
142 | ret += cb((void *)buf, strlen(buf), u); | 145 | if ((written = cb((void *)buf, strlen(buf), u)) < 0) |
146 | return -1; | ||
147 | ret += written; | ||
143 | } | 148 | } |
144 | #endif | 149 | #endif |
145 | return (ret); | 150 | return (ret); |