aboutsummaryrefslogtreecommitdiffstats
path: root/device/indextable.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2020-06-22 12:58:01 -0700
committerDavid Crawshaw <crawshaw@tailscale.com>2020-07-15 06:59:44 +1000
commit31b574ef99a79fb654085693423f48a3bf0e7f81 (patch)
tree5d6a9ac28d54e113758431d5a10d5306e6e5c0f0 /device/indextable.go
parentdevice: use RTMGRP_IPV4_ROUTE to specify multicast groups mask (diff)
downloadwireguard-go-31b574ef99a79fb654085693423f48a3bf0e7f81.tar.xz
wireguard-go-31b574ef99a79fb654085693423f48a3bf0e7f81.zip
device: remove some unnecessary unsafe
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Diffstat (limited to 'device/indextable.go')
-rw-r--r--device/indextable.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/device/indextable.go b/device/indextable.go
index 5e10eef..d2dc8a7 100644
--- a/device/indextable.go
+++ b/device/indextable.go
@@ -7,8 +7,8 @@ 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() {