diff options
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/random.cxx | 5 | ||||
-rw-r--r-- | sal/rtl/uuid.cxx | 26 |
2 files changed, 7 insertions, 24 deletions
diff --git a/sal/rtl/random.cxx b/sal/rtl/random.cxx index 8420d4ca8049..dd57103cfc8a 100644 --- a/sal/rtl/random.cxx +++ b/sal/rtl/random.cxx @@ -63,12 +63,11 @@ rtlRandomError SAL_CALL rtl_random_addBytes( } rtlRandomError SAL_CALL rtl_random_getBytes ( - rtlRandomPool Pool, void *Buffer, sal_Size Bytes) SAL_THROW_EXTERN_C() + rtlRandomPool, void *Buffer, sal_Size Bytes) SAL_THROW_EXTERN_C() { - RandomPool_Impl *pImpl = static_cast< RandomPool_Impl* >(Pool); sal_uInt8 *pBuffer = static_cast< sal_uInt8* >(Buffer); - if (!pImpl || !pBuffer) + if (!pBuffer) return rtl_Random_E_Argument; if (!osl_get_system_random_data(static_cast<char*>(Buffer), Bytes)) diff --git a/sal/rtl/uuid.cxx b/sal/rtl/uuid.cxx index 22e7f0fe0416..4249c7bddedb 100644 --- a/sal/rtl/uuid.cxx +++ b/sal/rtl/uuid.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <mutex> #include <string.h> #include <stdlib.h> @@ -84,28 +83,13 @@ extern "C" void SAL_CALL rtl_createUuid(sal_uInt8 *pTargetUUID , SAL_UNUSED_PARAMETER const sal_uInt8 *, SAL_UNUSED_PARAMETER sal_Bool) { + if (rtl_random_getBytes(nullptr, pTargetUUID, 16) != rtl_Random_E_None) { - static rtlRandomPool pool = []() { - rtlRandomPool aPool = rtl_random_createPool(); - if (!aPool) - { - abort(); - // only possible way to signal failure here (rtl_createUuid - // being part of a fixed C API) - } - return aPool; - }(); - - static std::mutex aMutex; - - std::scoped_lock g(aMutex); - if (rtl_random_getBytes(pool, pTargetUUID, 16) != rtl_Random_E_None) - { - abort(); - // only possible way to signal failure here (rtl_createUuid - // being part of a fixed C API) - } + abort(); + // only possible way to signal failure here (rtl_createUuid + // being part of a fixed C API) } + // See ITU-T Recommendation X.667: pTargetUUID[6] &= 0x0F; pTargetUUID[6] |= 0x40; |