diff options
author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2016-01-30 20:38:08 -0500 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-02-01 08:43:27 -0500 |
commit | a38a159bfcbc94214dda00e0e6b1fc6454a23b78 (patch) | |
tree | 20f69030db60f02b2f3530eb5d772a5fedfbe186 /crypto/bio | |
parent | e0fde613acb2dcd5be0750f002e80bf345401a2e (diff) |
RT4129: BUF_new_mem_buf should take const void *
Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 8ab31975bacb9c907261088937d3aa4102e3af84)
Diffstat (limited to 'crypto/bio')
-rw-r--r-- | crypto/bio/bio.h | 2 | ||||
-rw-r--r-- | crypto/bio/bss_mem.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/crypto/bio/bio.h b/crypto/bio/bio.h index 498cc32a8c..6790aed28e 100644 --- a/crypto/bio/bio.h +++ b/crypto/bio/bio.h @@ -689,7 +689,7 @@ long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, long ret); BIO_METHOD *BIO_s_mem(void); -BIO *BIO_new_mem_buf(void *buf, int len); +BIO *BIO_new_mem_buf(const void *buf, int len); BIO_METHOD *BIO_s_socket(void); BIO_METHOD *BIO_s_connect(void); BIO_METHOD *BIO_s_accept(void); diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c index d190765dc2..b0394a960d 100644 --- a/crypto/bio/bss_mem.c +++ b/crypto/bio/bss_mem.c @@ -91,7 +91,8 @@ BIO_METHOD *BIO_s_mem(void) return (&mem_method); } -BIO *BIO_new_mem_buf(void *buf, int len) + +BIO *BIO_new_mem_buf(const void *buf, int len) { BIO *ret; BUF_MEM *b; @@ -105,7 +106,8 @@ BIO *BIO_new_mem_buf(void *buf, int len) if (!(ret = BIO_new(BIO_s_mem()))) return NULL; b = (BUF_MEM *)ret->ptr; - b->data = buf; + /* Cast away const and trust in the MEM_RDONLY flag. */ + b->data = (void *)buf; b->length = sz; b->max = sz; ret->flags |= BIO_FLAGS_MEM_RDONLY; |