4

First I create Memory BIO like this

BIO *mem = BIO_new(BIO_s_mem());
BIO_puts(mem, "Hello World\n");

and get the pointer like this

BUF_MEM *bptr;
BIO_get_mem_ptr(mem, &bptr);

My doubt is how can I write and read by using bptr pointer?
Is this possible..?

TamiL
  • 2,706
  • 4
  • 24
  • 44
  • Take a look at https://stackoverflow.com/questions/49036152/correct-way-to-write-and-read-a-null-terminated-string-with-an-openssl-memory-bi – Jaime Hablutzel Feb 28 '18 at 22:09

1 Answers1

1

Definition of BUF_MEM is as follows:

typedef struct buf_mem_st BUF_MEM;
struct buf_mem_st
{
size_t length;  /* current number of bytes */
char *data;
size_t max; /* size of buffer */
};

You can see it is basically a wrapper over char * buffer. You can access data and perform read and write operations (while maintaining constraint of length and max of the structure).

doptimusprime
  • 9,115
  • 6
  • 52
  • 90