aboutsummaryrefslogtreecommitdiff
path: root/secure/lib/libcrypto/man/man3/BIO_s_mem.3
diff options
context:
space:
mode:
Diffstat (limited to 'secure/lib/libcrypto/man/man3/BIO_s_mem.3')
-rw-r--r--secure/lib/libcrypto/man/man3/BIO_s_mem.347
1 files changed, 35 insertions, 12 deletions
diff --git a/secure/lib/libcrypto/man/man3/BIO_s_mem.3 b/secure/lib/libcrypto/man/man3/BIO_s_mem.3
index 6b617083602f..5809e2963fcc 100644
--- a/secure/lib/libcrypto/man/man3/BIO_s_mem.3
+++ b/secure/lib/libcrypto/man/man3/BIO_s_mem.3
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)
+.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
.\"
.\" Standard preamble:
.\" ========================================================================
@@ -68,8 +68,6 @@
. \}
.\}
.rr rF
-.\"
-.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
@@ -132,14 +130,16 @@
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
-.IX Title "BIO_S_MEM 3"
-.TH BIO_S_MEM 3 "2022-06-21" "1.1.1p" "OpenSSL"
+.IX Title "BIO_S_MEM 3ossl"
+.TH BIO_S_MEM 3ossl "2023-09-19" "3.0.11" "OpenSSL"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
-BIO_s_secmem, BIO_s_mem, BIO_set_mem_eof_return, BIO_get_mem_data, BIO_set_mem_buf, BIO_get_mem_ptr, BIO_new_mem_buf \- memory BIO
+BIO_s_secmem,
+BIO_s_mem, BIO_set_mem_eof_return, BIO_get_mem_data, BIO_set_mem_buf,
+BIO_get_mem_ptr, BIO_new_mem_buf \- memory BIO
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
@@ -148,10 +148,10 @@ BIO_s_secmem, BIO_s_mem, BIO_set_mem_eof_return, BIO_get_mem_data, BIO_set_mem_b
\& const BIO_METHOD *BIO_s_mem(void);
\& const BIO_METHOD *BIO_s_secmem(void);
\&
-\& BIO_set_mem_eof_return(BIO *b, int v)
-\& long BIO_get_mem_data(BIO *b, char **pp)
-\& BIO_set_mem_buf(BIO *b, BUF_MEM *bm, int c)
-\& BIO_get_mem_ptr(BIO *b, BUF_MEM **pp)
+\& BIO_set_mem_eof_return(BIO *b, int v);
+\& long BIO_get_mem_data(BIO *b, char **pp);
+\& BIO_set_mem_buf(BIO *b, BUF_MEM *bm, int c);
+\& BIO_get_mem_ptr(BIO *b, BUF_MEM **pp);
\&
\& BIO *BIO_new_mem_buf(const void *buf, int len);
.Ve
@@ -194,6 +194,8 @@ positive return value \fBv\fR should be set to a negative value, typically \-1.
.PP
\&\fBBIO_get_mem_data()\fR sets *\fBpp\fR to a pointer to the start of the memory BIOs data
and returns the total amount of data available. It is implemented as a macro.
+Note the pointer returned by this call is informative, no transfer of ownership
+of this memory is implied. See notes on \fBBIO_set_close()\fR.
.PP
\&\fBBIO_set_mem_buf()\fR sets the internal \s-1BUF_MEM\s0 structure to \fBbm\fR and sets the
close flag to \fBc\fR, that is \fBc\fR should be either \s-1BIO_CLOSE\s0 or \s-1BIO_NOCLOSE.\s0
@@ -247,6 +249,10 @@ preceding that write operation cannot be undone.
.PP
Calling \fBBIO_get_mem_ptr()\fR prior to a \fBBIO_reset()\fR call with
\&\s-1BIO_FLAGS_NONCLEAR_RST\s0 set has the same effect as a write operation.
+.PP
+Calling \fBBIO_set_close()\fR with \s-1BIO_NOCLOSE\s0 orphans the \s-1BUF_MEM\s0 internal to the
+\&\s-1BIO,\s0 _not_ its actual data buffer. See the examples section for the proper
+method for claiming ownership of the data pointer for a deferred free operation.
.SH "BUGS"
.IX Header "BUGS"
There should be an option to set the maximum size of a memory \s-1BIO.\s0
@@ -287,11 +293,28 @@ Extract the \s-1BUF_MEM\s0 structure from a memory \s-1BIO\s0 and then free up t
\& BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free() leaves BUF_MEM alone */
\& BIO_free(mem);
.Ve
+.PP
+Extract the \s-1BUF_MEM\s0 ptr, claim ownership of the internal data and free the \s-1BIO\s0
+and \s-1BUF_MEM\s0 structure:
+.PP
+.Vb 2
+\& BUF_MEM *bptr;
+\& char *data;
+\&
+\& BIO_get_mem_data(bio, &data);
+\& BIO_get_mem_ptr(bio, &bptr);
+\& BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free orphans BUF_MEM */
+\& BIO_free(bio);
+\& bptr\->data = NULL; /* Tell BUF_MEM to orphan data */
+\& BUF_MEM_free(bptr);
+\& ...
+\& free(data);
+.Ve
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
-Copyright 2000\-2019 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000\-2023 The OpenSSL Project Authors. All Rights Reserved.
.PP
-Licensed under the OpenSSL license (the \*(L"License\*(R"). You may not use
+Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file \s-1LICENSE\s0 in the source distribution or at
<https://www.openssl.org/source/license.html>.