如果您执行以下示例(几乎完全基于官方https://www.openssl.org/docs/man1.0.2/crypto/crypto/bio_s_mem.mem.html#example(:
#include <openssl/bio.h>
#include <openssl/buffer.h>
int main() {
BIO *mem = BIO_new(BIO_s_mem());
BIO_puts(mem, "Hello Worldn");
BUF_MEM *bptr;
BIO_get_mem_ptr(mem, &bptr);
BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free() leaves BUF_MEM alone */
BIO_free(mem);
printf("%s", bptr->data);
BUF_MEM_free(bptr);
return 0;
}
它只是可能会按预期工作,这取决于n
之后的基础内存缓冲区中的未隔离char
是偶然的