Dynamic / shared library is loaded twice / RSA _check_key does not work if libcrypto is loaded both statically and dynamically

Original problem:

I currently have a program that loads two shared libraries a.so and b.so dynamically. Both libraries load libcrypto.so (OpenSSL). If the program ends, there is double free or corrupted error

. I have already checked my program for errors. Indexes are in bounds and heap is not used.

It seems to me that the libcrypto.so library is split twice at the end of the program. Is there a way to prevent this? Preferably without using different instances of libssl as storage and memory are in close proximity.

Im using Ubuntu 14.04 LTS wrote libraries in C and compiled using gcc with -fpic.

Thank you for your help!

PS: May be related: Static library is loaded twice

// Edit: The same problem occurs if a.so and b.so link libssl statically.

/// Edit: The same problem occurs if the links a.so are static and b.so is dynamic. (a.so is used first). If a.so is linked dynamically and b.so is statically linked, an error in libcrypto occurs on RSA_check_key(..)

.

Answer

//// Edit: I combined my code even more and found that I was additionally binding something twice statically. This caused the first problem

New problem:

As mentioned in the second edit, RSA_check_key fails if libcrypto was linked statically first and then dynamically. Any ideas what happened here?

+3


source to share


1 answer


What error is being returned? If not already done, check out https://www.openssl.org/docs/crypto/RSA_check_key.html



0


source







All Articles