If dynamically-loadable ENGINEs are linked against a shared-library version
authorRichard Levitte <levitte@openssl.org>
Thu, 27 Nov 2003 16:41:26 +0000 (16:41 +0000)
committerRichard Levitte <levitte@openssl.org>
Thu, 27 Nov 2003 16:41:26 +0000 (16:41 +0000)
commit04dc4edb447b4203c29b654a7beba61507eadc7b
treebe18f245da2572a6a1126aecf4ad3e88dc9cc582
parentd161f5a9b26c751682dca4c4cc08fab6cf88ee1d
If dynamically-loadable ENGINEs are linked against a shared-library version
of libcrypto, then it is possible that when they are loaded they will share
the same static data as the loading application/library. This means it will
be too late to set memory/ERR/ex_data/[etc] callbacks, but entirely
unnecessary to try.

This change (and a great part of this comment) was implemented in
0.9.8-dev a long time ago, but slightly differently.  In 0.9.8-dev, a
specific function that just returns a pointer to some static object is
used. For 0.9.7x, we couldn't do that, since the way we handle feature
freezes is, among other, to not add any more non-static functions.
Instead, we use the function ERR_get_implementation() and compare the
returned value with fns->err_fns, a member of fns that already is
there, and which therefore can safely be used in this manner.

What happens is that if the loaded ENGINE's return value from this
function matches the loading application/library's return value - they
share static data. If they don't match, the loaded ENGINE has its own
copy of libcrypto's static data and so the callbacks need to be set.
crypto/engine/engine.h