diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-10-28 23:45:40 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-10-31 10:22:46 +0100 |
commit | f28f87f20c040d941d7a5e64c6b662a23744a21b (patch) | |
tree | fdee0a05b72a66d273be347c36523f244e04c5a9 /sw | |
parent | 9fd3a83e47e94801e6f4c9a432e8459b8320aabc (diff) |
sw: RSID have no need for cryptographic randomness
Change-Id: I4a3c4e390a6d05059e27ca33f02c38cfb6bb2e47
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/doc.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 7 |
2 files changed, 5 insertions, 10 deletions
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 6aea833707c9..e3ae223b6b84 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -42,7 +42,6 @@ #include <hintids.hxx> #include <tools/globname.hxx> #include <svx/svxids.hrc> -#include <rtl/random.h> #include <com/sun/star/i18n/WordType.hpp> #include <com/sun/star/i18n/ForbiddenCharacters.hpp> @@ -52,6 +51,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <comphelper/string.hxx> +#include <comphelper/random.hxx> #include <tools/urlobj.hxx> #include <tools/poly.hxx> #include <tools/multisel.hxx> @@ -245,10 +245,8 @@ void SwDoc::setRsid( sal_uInt32 nVal ) { // Increase the rsid with a random number smaller than 2^17. This way we // expect to be able to edit a document 2^12 times before rsid overflows. - static rtlRandomPool aPool = rtl_random_createPool(); - rtl_random_getBytes( aPool, &nIncrease, sizeof ( nIncrease ) ); - nIncrease &= ( 1<<17 ) - 1; - nIncrease++; // make sure the new rsid is not the same + // start from 1 to ensure the new rsid is not the same + nIncrease = comphelper::rng::uniform_uint_distribution(1, (1 << 17) - 1); } mnRsid = nVal + nIncrease; } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 8cd2dc936395..37cb1227f1a2 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -28,9 +28,9 @@ #include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/random.hxx> #include <vcl/svapp.hxx> #include <vcl/virdev.hxx> -#include <rtl/random.h> #include <sfx2/printer.hxx> #include <sfx2/docfile.hxx> #include <sfx2/frame.hxx> @@ -367,10 +367,7 @@ SwDoc::SwDoc() { // Initialize the session id of the current document to a random number // smaller than 2^21. - static rtlRandomPool aPool = rtl_random_createPool(); - rtl_random_getBytes( aPool, &mnRsid, sizeof ( mnRsid ) ); - mnRsid &= ( 1<<21 ) - 1; - mnRsid++; + mnRsid = comphelper::rng::uniform_uint_distribution(1, (1 << 21) - 1); } mnRsidRoot = mnRsid; |