diff options
author | Matt Caswell <matt@openssl.org> | 2016-09-05 17:26:58 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-10-28 09:48:54 +0100 |
commit | d07aee2c7a33e77d97d8e13811af3637e3849cb2 (patch) | |
tree | 1c3452687dbd734f4e739713f29fbf770f5524dd /crypto/bio/bio_meth.c | |
parent | 229bd12487f8576fc088dc4f641950ac33c62033 (diff) |
Create BIO_read_ex() which handles size_t arguments
Also extend BIO_METHOD to be able to supply an implementation for the new
BIO_read function.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/bio/bio_meth.c')
-rw-r--r-- | crypto/bio/bio_meth.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/crypto/bio/bio_meth.c b/crypto/bio/bio_meth.c index c5f9f7e8e7..c10f8d01d1 100644 --- a/crypto/bio/bio_meth.c +++ b/crypto/bio/bio_meth.c @@ -63,12 +63,45 @@ int BIO_meth_set_write(BIO_METHOD *biom, int (*BIO_meth_get_read(BIO_METHOD *biom)) (BIO *, char *, int) { + return biom->bread_old; +} + +int (*BIO_meth_get_read_ex(BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *) +{ return biom->bread; } +/* Conversion for old style bread to new style */ +int bread_conv(BIO *bio, char *out, size_t outl, size_t *read) +{ + int ret; + + if (outl > INT_MAX) + return 0; + + ret = bio->method->bread_old(bio, out, (int)outl); + + if (ret <= 0) { + *read = 0; + return ret; + } + + *read = (size_t)ret; + + return 1; +} + int BIO_meth_set_read(BIO_METHOD *biom, int (*bread) (BIO *, char *, int)) { + biom->bread_old = bread; + biom->bread = bread_conv; + return 1; +} + +int BIO_meth_set_read_ex(BIO_METHOD *biom, + int (*bread) (BIO *, char *, size_t, size_t *)) +{ biom->bread = bread; return 1; } |