aboutsummaryrefslogtreecommitdiffstats
path: root/src/cert/cvc/eac_obj.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-01-22 20:57:42 +0000
committerlloyd <[email protected]>2010-01-22 20:57:42 +0000
commitd490659cd20c73f5e269b2e5f471512927df8ca7 (patch)
treed75f0bf5681ede557e99088091467e106b17bee5 /src/cert/cvc/eac_obj.h
parentc9672d69689b7bdbec89ab2a9193aaca948acb76 (diff)
Prevent a crash in GMP_Engine if the library is shutdown and then
reinitialized. It would cache an Allocator pointer on first use, and then never zero it, so after the reinit the pointer would be going to a now deallocated Allocator object. Encountered in the SoftHSM test suite, reported by Ondrej Sury. Use a simple reference counting scheme to zero the pointer, and reset the GNU MP memory functions. This also fixes a quite obscure and never reported bug, that if the GMP engine was used, and if the library was deinitialized but then the program tried to use GNU MP, the allocator functions would crash. Now after deinit the allocator funcs revert to the defaults. The reference count is not updated atomically so this is not thread safe, but seems a non-issue; the only time this could happen (especially now that the GMP engine header is internal-only) is if multiple threads were attempting to initialize / shutdown the library at once - which won't work anyway for a variety of reasons, including contention on the (unlocked) global_lib_state pointer. If at some point thread safety is useful here, the refcnt can be locked by a mutex, or kept in an atomic<unsigned int>.
Diffstat (limited to 'src/cert/cvc/eac_obj.h')
0 files changed, 0 insertions, 0 deletions