diff options
Diffstat (limited to 'device/indextable.go')
-rw-r--r-- | device/indextable.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/device/indextable.go b/device/indextable.go index 4cba970..00ade7d 100644 --- a/device/indextable.go +++ b/device/indextable.go @@ -1,14 +1,14 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device import ( "crypto/rand" + "encoding/binary" "sync" - "unsafe" ) type IndexTableEntry struct { @@ -25,7 +25,8 @@ type IndexTable struct { func randUint32() (uint32, error) { var integer [4]byte _, err := rand.Read(integer[:]) - return *(*uint32)(unsafe.Pointer(&integer[0])), err + // Arbitrary endianness; both are intrinsified by the Go compiler. + return binary.LittleEndian.Uint32(integer[:]), err } func (table *IndexTable) Init() { |