]> Cypherpunks repositories - gostls13.git/commit
crypto/x509: make '-gcflags=all=-d=checkptr' flag work
authorAlex Brainman <alex.brainman@gmail.com>
Sat, 2 Nov 2019 23:32:37 +0000 (10:32 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Sun, 3 Nov 2019 01:44:46 +0000 (01:44 +0000)
commitd2c039fb210429958bce6347a1e9d9a7b0ffd26d
tree018dffe7539e40c25bfa3dcdf47535b462a1c3b2
parent3873e5497d21979910a1ec7cf90a34577fa1f6ae
crypto/x509: make '-gcflags=all=-d=checkptr' flag work

Replace

buf := [HUGE_CONST]*T)(unsafe.Pointer(p))[:]

with

buf := [HUGE_CONST]*T)(unsafe.Pointer(p))[:n:n]

Pointer p points to n of T elements. New unsafe pointer conversion
logic verifies that both first and last elements point into the
same Go variable. And this change adjusts all code to comply with
this rule.

Verified by running

go test -a -short -gcflags=all=-d=checkptr crypto/x509

The test does not fail even with original version of this code. I
suspect it is because all variables I changed live outside of Go
memory. But I am just guessing, I don't really know how pointer
checker works.

Updates golang/go#34972

Change-Id: Ibc33fdc9e2023d9b14905c9badf2f0b683999ab8
Reviewed-on: https://go-review.googlesource.com/c/go/+/204621
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/crypto/x509/root_windows.go