]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: source startupRandomData from auxv AT_RANDOM on linux/arm.
authorShenghou Ma <minux@golang.org>
Fri, 9 Jan 2015 00:09:56 +0000 (19:09 -0500)
committerMinux Ma <minux@golang.org>
Fri, 9 Jan 2015 06:50:11 +0000 (06:50 +0000)
Fixes #9541.

Change-Id: I5d659ad50d7c3d1c92ed9feb86cda4c1a6e62054
Reviewed-on: https://go-review.googlesource.com/2584
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/os_linux_arm.go

index d5b37d6ab5b315082503447a32391d52cc56cb4a..fea5dcafd476170a25cce958565e5cc018437d58 100644 (file)
@@ -51,12 +51,11 @@ func setup_auxv(argc int32, argv **byte) {
        for i := 0; auxv[i] != _AT_NULL; i += 2 {
                switch auxv[i] {
                case _AT_RANDOM: // kernel provides a pointer to 16-bytes worth of random data
-                       if auxv[i+1] != 0 {
-                               // the pointer provided may not be word alined, so we must to treat it
-                               // as a byte array.
-                               rnd := (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))
-                               randomNumber = uint32(rnd[0]) | uint32(rnd[1])<<8 | uint32(rnd[2])<<16 | uint32(rnd[3])<<24
-                       }
+                       startupRandomData = (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))[:]
+                       // the pointer provided may not be word alined, so we must to treat it
+                       // as a byte array.
+                       randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
+                               uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
 
                case _AT_PLATFORM: // v5l, v6l, v7l
                        t := *(*uint8)(unsafe.Pointer(uintptr(auxv[i+1] + 1)))