diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-03 17:12:23 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-06 14:13:27 +0100 |
commit | 8f436d3de7e99268a8862664d2cb2574231c3b18 (patch) | |
tree | 0a07dd3cecbd7bc5b0293006bb8691e33c5cca75 /desktop | |
parent | e5ab3685550cf35c3eb9cb47530044f2d86433d5 (diff) |
use comphelper::rng::uniform_*_distribution everywhere
and automatically seed from time on first use
coverity#1242393 Don't call rand
coverity#1242404 Don't call rand
coverity#1242410 Don't call rand and additionally allow 0xFF as a value
coverity#1242409 Don't call rand
coverity#1242399 Don't call rand
coverity#1242372 Don't call rand
coverity#1242377 Don't call rand
coverity#1242378 Don't call rand
coverity#1242379 Don't call rand
coverity#1242382 Don't call rand
coverity#1242383 Don't call rand
coverity#1242402 Don't call rand
coverity#1242397 Don't call rand
coverity#1242390 Don't call rand
coverity#1242389 Don't call rand
coverity#1242388 Don't call rand
coverity#1242386 Don't call rand
coverity#1242384 Don't call rand
coverity#1242394 Don't call rand
Change-Id: I241feab9cb370e091fd6ccaba2af941eb95bc7cf
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/deployment/misc/lockfile.cxx | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/desktop/source/deployment/misc/lockfile.cxx b/desktop/source/deployment/misc/lockfile.cxx index 96d9dce076db..1f3d2f2a86ce 100644 --- a/desktop/source/deployment/misc/lockfile.cxx +++ b/desktop/source/deployment/misc/lockfile.cxx @@ -24,6 +24,7 @@ #else #include <windows.h> #endif +#include <comphelper/random.hxx> #include <sal/types.h> #include <osl/file.hxx> #include <osl/socket.hxx> @@ -33,7 +34,6 @@ #include "lockfile.hxx" - using namespace ::osl; using namespace ::rtl; using namespace ::utl; @@ -85,11 +85,9 @@ namespace desktop { // generate ID const int nIdBytes = 16; char tmpId[nIdBytes*2+1]; - time_t t; - srand( (unsigned)(t = time( NULL )) ); - int tmpByte = 0; + time_t t = time(NULL); for (int i = 0; i<nIdBytes; i++) { - tmpByte = rand( ) % 0xFF; + int tmpByte = comphelper::rng::uniform_int_distribution(0, 0xFF); sprintf( tmpId+i*2, "%02X", tmpByte ); } tmpId[nIdBytes*2]=0x00; |