BIO in memory usage....

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

BIO in memory usage....

Tobias Wolf

I`d like to understand how a memory bio can be reseted with the internal read counter back to zero for further reusage.

 

e.g.

I want to try to read first der and then pem

 

d2i_X509

 

and then:

 

PEM_read_X509

 

Then the second call will fail because the bio has already read some bytes, when I call each function with a newly created bio it is working fine.

I already tried with BIO_seek, BIO_tell (returns 0?!), BIO_reset.

 

Reply | Threaded
Open this post in threaded view
|

Re: BIO in memory usage....

d3x0r


On Sun, Jun 16, 2019 at 3:17 AM Tobias Wolf <[hidden email]> wrote:

I`d like to understand how a memory bio can be reseted with the internal read counter back to zero for further reusage.

 

e.g.

I want to try to read first der and then pem

 

d2i_X509

 

and then:

 

PEM_read_X509

 

Then the second call will fail because the bio has already read some bytes, when I call each function with a newly created bio it is working fine.

I already tried with BIO_seek, BIO_tell (returns 0?!), BIO_reset.


After reset did you also refill it?  

 

Reply | Threaded
Open this post in threaded view
|

Re: BIO in memory usage....

Tomas Mraz-2
In reply to this post by Tobias Wolf
On Sun, 2019-06-16 at 12:11 +0200, Tobias Wolf wrote:

> I`d like to understand how a memory bio can be reseted with the
> internal read counter back to zero for further reusage.
>  
> e.g.
> I want to try to read first der and then pem
>  
> d2i_X509
>  
> and then:
>  
> PEM_read_X509
>  
> Then the second call will fail because the bio has already read some
> bytes, when I call each function with a newly created bio it is
> working fine.
> I already tried with BIO_seek, BIO_tell (returns 0?!), BIO_reset.

If the BIO is read-only (created with BIO_new_mem_buf()) the BIO_reset
will work as you expect.

Please also see the NOTES section of BIO_s_mem manpage.

--
Tomáš Mráz
No matter how far down the wrong road you've gone, turn back.
                                              Turkish proverb
[You'll know whether the road is wrong if you carefully listen to your
conscience.]