Comment 9 for bug 1543455

Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2017-07-20 05:36 EDT-------
Catched the reason:
All the internal function pointers in libibmca are NULL. So the sha1 call jumps over zero ;-). The reason why all the function pointers are NULL is simple because the ibmca engine init function ibmca_init() is called 3 (!!!) times.
The start of this function is:

static int ibmca_init(ENGINE * e)
{
static int init = 0;

if (ibmca_dso != NULL && init >= 2) {
IBMCAerr(IBMCA_F_IBMCA_INIT, IBMCA_R_ALREADY_LOADED);
goto err;
}

so init values >= 2 will cause the code to jump to the err label where all internal function pointers are set to NULL. Tracing shows this very clear. The first init works fine, the second similar but the third init now decides to clear the function pointers and that's it.

Solution: Calling init more than once is certainly a feature :-). However, a rework of the code like this:

static int ibmca_init(ENGINE * e)
{
static int init = 0;

if (init > 0)
return 1;

and everything is fine. So openssl call the engine's init function as often as wanted it does no harm.

I'll attach a patch. Paulo please review the patch, maybe comment and rework and integrate this or another solution into the ibmca engine.
regards
H.Freudenberger