Debian Codegraph @

libgo/go/crypto/sha1/issue15617_test.go

raw
1 //go:build amd64 && (linux || darwin)
2
3 // Copyright 2016 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package sha1_test
8
9 import (
10 "crypto/sha1"
11 "syscall"
12 "testing"
13 )
14
15 func TestOutOfBoundsRead(t *testing.T) {
16 const pageSize = 4 << 10
17 data, err := syscall.Mmap(0, 0, 2*pageSize, syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_ANON|syscall.MAP_PRIVATE)
18 if err != nil {
19 panic(err)
20 }
21 if err := syscall.Mprotect(data[pageSize:], syscall.PROT_NONE); err != nil {
22 panic(err)
23 }
24 for i := 0; i < pageSize; i++ {
25 sha1.Sum(data[pageSize-i : pageSize])
26 }
27 }