FWIW, I absolutely disagree with how the openssl team solved the heartbleed bug.
Fist of all, the very issue of the problem originates not at
this change, but at
this one (or maybe even sooner, when they introduced an internal memory heap, to the library).
"Memory saving patch" - really?
This guy wrapped it up very well:
http://article.gmane.org/gmane.os.openbsd.misc/211963Had they not introduced the own heap to openssl in the first place, this heartbleed bug would have been causing memory access violation and the issue would be spotted long ego.
Moreover, the only reason for a security lib to have its own heap manager is to provide more security - meaning: make sure to clear all the memory while freeing it.
What this heap does instead is actually making sure that no memory is being cleared, no matter how you had built the lib!
So whatever buffer you allocate, in whatever function, there is a decent change that you will get it filled with some crucial data, like a private key used just a moment ago.
And therefore, knowing life, I am pretty certain that there are also other functions that leak the private data from openssl's internal heap - its just a matter of time before someone finds them.
The proper way to fix that issue was by fixing the internal heap (make it to clear the memory while being freed), or just removing it because it wasn't necessary in the first place.
But definitively not just fixing it
like this, abstracting from the actual original cause.
At the other hand, it is a developer's (who uses this lib) duty to clear up all the crucial data from the memory, before freeing any buffer that would contain it, and preferably even sooner; as soon as the crucial data isn't needed anymore.
But apparently only few developers actually do that and bitcoin core devels don't seem to be on that list... at last as far as I had checked this code.
So, shame on you too!