RT4129: BUF_new_mem_buf should take const void *
[openssl.git] / crypto / bio / bss_mem.c
index 4a0fcdaa8f69c49d69d95e5d5f884278d7a272dc..4d4554719ca4856838c3dc2d76b4c6cc07d65f57 100644 (file)
@@ -108,7 +108,7 @@ BIO_METHOD *BIO_s_secmem(void)
     return(&secmem_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;
@@ -122,7 +122,8 @@ BIO *BIO_new_mem_buf(void *buf, int len)
     if ((ret = BIO_new(BIO_s_mem())) == NULL)
         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;