Source file
src/crypto/sha1/issue15617_test.go
1
2
3
4
5
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 }
28
View as plain text