nfs4: let nfs4 use kernel utils for random numbers
This commit is contained in:
parent
5c455f803f
commit
b56330de8e
@ -16,8 +16,9 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <util/kernel_cpp.h>
|
||||
#include <net/dns_resolver.h>
|
||||
#include <util/kernel_cpp.h>
|
||||
#include <util/Random.h>
|
||||
|
||||
|
||||
#define NFS4_PORT 2049
|
||||
@ -655,7 +656,7 @@ Connection::Connect()
|
||||
PeerAddress address(fPeerAddress.Family());
|
||||
|
||||
do {
|
||||
port = rand() % (IPPORT_RESERVED - NFS_MIN_PORT);
|
||||
port = get_random<uint16>() % (IPPORT_RESERVED - NFS_MIN_PORT);
|
||||
port += NFS_MIN_PORT;
|
||||
|
||||
if (attempt == 9)
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <lock.h>
|
||||
#include <util/Random.h>
|
||||
|
||||
#include "Request.h"
|
||||
#include "RootInode.h"
|
||||
@ -32,9 +33,7 @@ FileSystem::FileSystem(const MountConfiguration& configuration)
|
||||
fId(1),
|
||||
fConfiguration(configuration)
|
||||
{
|
||||
fOpenOwner = rand();
|
||||
fOpenOwner <<= 32;
|
||||
fOpenOwner |= rand();
|
||||
fOpenOwner = get_random<uint64>();
|
||||
|
||||
mutex_init(&fOpenOwnerLock, NULL);
|
||||
mutex_init(&fOpenLock, NULL);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <util/AutoLock.h>
|
||||
#include <util/Random.h>
|
||||
|
||||
#include "RPCCallbackServer.h"
|
||||
#include "RPCReply.h"
|
||||
@ -83,7 +84,7 @@ Server::Server(Connection* connection, PeerAddress* address)
|
||||
fPrivateData(NULL),
|
||||
fCallback(NULL),
|
||||
fRepairCount(0),
|
||||
fXID(rand() << 1)
|
||||
fXID(get_random<uint32>())
|
||||
{
|
||||
ASSERT(connection != NULL);
|
||||
ASSERT(address != NULL);
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <util/Random.h>
|
||||
|
||||
#include "Cookie.h"
|
||||
#include "OpenState.h"
|
||||
#include "RPCCallback.h"
|
||||
@ -659,8 +661,7 @@ RequestBuilder::SetClientID(RPC::Server* server)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
fRequest->Stream().AddUInt(OpSetClientID);
|
||||
uint64 verifier = rand();
|
||||
verifier = verifier << 32 | rand();
|
||||
uint64 verifier = get_random<uint64>();
|
||||
fRequest->Stream().AddUHyper(verifier);
|
||||
|
||||
status_t result = _GenerateClientId(fRequest->Stream(), server);
|
||||
|
Loading…
Reference in New Issue
Block a user