[openssl-dev] "openssl s_client" memory leak

Gisle Vanem gvanem at yahoo.no
Wed Jan 20 15:24:25 UTC 2016


Gisle Vanem wrote:

> And adding other options show additional leaks.
> E.g. '-nbio_test -reconnect' results in 12 leaks:
> 
>   [12:15:17] 13704 file=crypto/bio/bio_lib.c, line=68, thread=4248, number=72, address=0x2ccf468
>   [12:15:15] 13016 file=crypto/bio/bio_lib.c, line=68, thread=4248, number=72, address=0x2ccedb0
...
>   [12:15:17] 14021 file=crypto/bio/bio_lib.c, line=68, thread=4248, number=72, address=0x2ccf628
>   864 bytes leaked in 12 chunks

I was curious to fix + understand why this leak happens. AFAICS
the execution-flow with the options '-reconnect' and '-nbio_test'
seems a bit funny. Because, in a brief of 's_client_main()' is:

  re_start:
  ...

  if (nbio_test) {
     BIO *test;
     test = BIO_new(BIO_f_nbio_test()); << ! leaks here AFAICS
     sbio = BIO_push(test, sbio);
  }
  ...

  if (reconnect) {
    reconnect--;
    ...
    goto re_start;
  }

-------------

According to 'man s_client', a reconnect should be performed 5 times:
 -reconnect
   reconnects to the same server 5 times using the same session ID,
   this can be used as a test that session caching is working.

But where is 'test' bio-freed?

Does it hurt the "session ID" that one does 'sbio = BIO_pop(sbio)'?
Or could the 're_start' label be moved *after* the BIO_new()? You
experts should take a look at this.

-- 
--gv


More information about the openssl-dev mailing list