diff options
| author | bcook <> | 2016-09-14 11:26:56 +0000 |
|---|---|---|
| committer | bcook <> | 2016-09-14 11:26:56 +0000 |
| commit | c844ce82949649adc9d6ee3b56e6c8954c099446 (patch) | |
| tree | 0940beba6d0ee06a3eec448624261e8f32fe8d26 /src | |
| parent | d38b15019a94267fb66852d97b372b090de32f83 (diff) | |
| download | openbsd-c844ce82949649adc9d6ee3b56e6c8954c099446.tar.gz openbsd-c844ce82949649adc9d6ee3b56e6c8954c099446.tar.bz2 openbsd-c844ce82949649adc9d6ee3b56e6c8954c099446.zip | |
Allow callback read/write functions to set TLS_WANT_POLLOUT/POLLIN.
from Tobias Pape
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libtls/tls_bio_cb.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/lib/libtls/tls_bio_cb.c b/src/lib/libtls/tls_bio_cb.c index e689cf1117..bee52a67f4 100644 --- a/src/lib/libtls/tls_bio_cb.c +++ b/src/lib/libtls/tls_bio_cb.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls_bio_cb.c,v 1.3 2016/09/04 13:17:08 jsing Exp $ */ | 1 | /* $OpenBSD: tls_bio_cb.c,v 1.4 2016/09/14 11:26:56 bcook Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2016 Tobias Pape <tobias@netshed.de> | 3 | * Copyright (c) 2016 Tobias Pape <tobias@netshed.de> |
| 4 | * | 4 | * |
| @@ -169,14 +169,32 @@ static int | |||
| 169 | tls_bio_write_cb(BIO *h, const char *buf, int num, void *cb_arg) | 169 | tls_bio_write_cb(BIO *h, const char *buf, int num, void *cb_arg) |
| 170 | { | 170 | { |
| 171 | struct tls *ctx = cb_arg; | 171 | struct tls *ctx = cb_arg; |
| 172 | return (ctx->write_cb)(ctx, buf, num, ctx->cb_arg); | 172 | BIO_clear_retry_flags(h); |
| 173 | int rv = (ctx->write_cb)(ctx, buf, num, ctx->cb_arg); | ||
| 174 | if (rv == TLS_WANT_POLLIN) { | ||
| 175 | BIO_set_retry_read(h); | ||
| 176 | rv = -1; | ||
| 177 | } else if (rv == TLS_WANT_POLLOUT) { | ||
| 178 | BIO_set_retry_write(h); | ||
| 179 | rv = -1; | ||
| 180 | } | ||
| 181 | return (rv); | ||
| 173 | } | 182 | } |
| 174 | 183 | ||
| 175 | static int | 184 | static int |
| 176 | tls_bio_read_cb(BIO *h, char *buf, int size, void *cb_arg) | 185 | tls_bio_read_cb(BIO *h, char *buf, int size, void *cb_arg) |
| 177 | { | 186 | { |
| 178 | struct tls *ctx = cb_arg; | 187 | struct tls *ctx = cb_arg; |
| 179 | return (ctx->read_cb)(ctx, buf, size, ctx->cb_arg); | 188 | BIO_clear_retry_flags(h); |
| 189 | int rv = (ctx->read_cb)(ctx, buf, size, ctx->cb_arg); | ||
| 190 | if (rv == TLS_WANT_POLLIN) { | ||
| 191 | BIO_set_retry_read(h); | ||
| 192 | rv = -1; | ||
| 193 | } else if (rv == TLS_WANT_POLLOUT) { | ||
| 194 | BIO_set_retry_write(h); | ||
| 195 | rv = -1; | ||
| 196 | } | ||
| 197 | return (rv); | ||
| 180 | } | 198 | } |
| 181 | 199 | ||
| 182 | static BIO * | 200 | static BIO * |
