diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bio/b_dump.c | 15 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/BIO_dump.3 | 33 |
2 files changed, 17 insertions, 31 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); |
diff --git a/src/lib/libcrypto/man/BIO_dump.3 b/src/lib/libcrypto/man/BIO_dump.3 index 88ae7d571d..1b66d95679 100644 --- a/src/lib/libcrypto/man/BIO_dump.3 +++ b/src/lib/libcrypto/man/BIO_dump.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: BIO_dump.3,v 1.1 2021/07/10 15:56:18 schwarze Exp $ | 1 | .\" $OpenBSD: BIO_dump.3,v 1.2 2021/07/11 20:18:07 beck Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> |
| 4 | .\" | 4 | .\" |
| @@ -14,7 +14,7 @@ | |||
| 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | .\" | 16 | .\" |
| 17 | .Dd $Mdocdate: July 10 2021 $ | 17 | .Dd $Mdocdate: July 11 2021 $ |
| 18 | .Dt BIO_DUMP 3 | 18 | .Dt BIO_DUMP 3 |
| 19 | .Os | 19 | .Os |
| 20 | .Sh NAME | 20 | .Sh NAME |
| @@ -98,24 +98,13 @@ are similar except that | |||
| 98 | is used instead of | 98 | is used instead of |
| 99 | .Xr BIO_write 3 . | 99 | .Xr BIO_write 3 . |
| 100 | .Sh RETURN VALUES | 100 | .Sh RETURN VALUES |
| 101 | These functions return the sum of the return values of all calls to | 101 | On success these functions return the total number of bytes written by |
| 102 | .Xr BIO_write 3 | 102 | .Xr BIO_write 3 |
| 103 | or | 103 | or |
| 104 | .Xr fwrite 3 | 104 | .Xr fwrite 3 . |
| 105 | that were made. | 105 | If a failure occurs at any point when writing, these |
| 106 | This is useless because it may add a positive number, the total amount | 106 | functions will stop after having potentially written out partial results, |
| 107 | of bytes written by successful calls to | 107 | and return -1. |
| 108 | .Xr BIO_write 3 , | ||
| 109 | to an incommensurable negative number, usually the number of calls to | ||
| 110 | .Xr BIO_write 3 | ||
| 111 | that failed. | ||
| 112 | All that can be said is that a negative return value indicates that | ||
| 113 | at least part of the printing failed, and a positive return value | ||
| 114 | indicates that at least some of the printing succeeded, but one | ||
| 115 | cannot tell whether success or failure were partial or complete. | ||
| 116 | Furthermore, a zero return value does not necessarily mean that | ||
| 117 | nothing was printed; it can also occur if a part of the printing | ||
| 118 | succeeded and another part failed. | ||
| 119 | .Sh SEE ALSO | 108 | .Sh SEE ALSO |
| 120 | .Xr hexdump 1 , | 109 | .Xr hexdump 1 , |
| 121 | .Xr BIO_new 3 , | 110 | .Xr BIO_new 3 , |
| @@ -134,11 +123,3 @@ and | |||
| 134 | .Fn BIO_dump_indent_fp | 123 | .Fn BIO_dump_indent_fp |
| 135 | first appeared in OpenSSL 0.9.8 and have been available since | 124 | first appeared in OpenSSL 0.9.8 and have been available since |
| 136 | .Ox 4.5 . | 125 | .Ox 4.5 . |
| 137 | .Sh BUGS | ||
| 138 | If some parts of the printing operations succeed | ||
| 139 | and some other parts fail, | ||
| 140 | .Fn BIO_dump | ||
| 141 | may silently yield incomplete results | ||
| 142 | such that the caller cannot detect the partial failure. | ||
| 143 | Besides, the function may have written more bytes than the return | ||
| 144 | value indicates. | ||
