Skip to content
This repository was archived by the owner on Oct 5, 2021. It is now read-only.

Commit f7f56f7

Browse files
authored
Run CI on x86 and x64. Fix some 32 bit problems.
2 parents b5c7743 + ce269e8 commit f7f56f7

3 files changed

Lines changed: 52 additions & 18 deletions

File tree

.appveyor.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
skip_branch_with_pr: true
2+
os: 'Visual Studio 2015'
3+
4+
build: off
5+
6+
environment:
7+
matrix:
8+
- ARCH: x64
9+
MSYS2_ARCH: x86_64
10+
MSYS2_DIR: msys64
11+
MSYSTEM: MINGW64
12+
GOPATH: c:\gopath
13+
GOROOT: c:\go
14+
GOARCH: amd64
15+
EXTLD: x86_64-w64-mingw32-gcc
16+
- ARCH: x86
17+
MSYS2_ARCH: i686
18+
MSYS2_DIR: msys64
19+
MSYSTEM: MINGW32
20+
GOPATH: c:\gopath
21+
GOROOT: c:\go
22+
GOARCH: 386
23+
EXTLD: i686-w64-mingw32-gcc
24+
25+
clone_folder: C:\gopath\src\github.com\mastahyeti\certstore
26+
27+
before_test:
28+
# Ensure CGO is enabled
29+
- set CGO_ENABLED=1
30+
# Go paths
31+
- set PATH=%GOROOT%\bin;C:\%GOPATH%\bin;%PATH%
32+
# MSYS paths
33+
- set PATH=C:\%MSYS2_DIR%\%MSYSTEM%\bin;C:\%MSYS2_DIR%\usr\bin;%PATH%
34+
# Install build deps
35+
- bash -lc "for n in `seq 1 3`; do pacman --noconfirm -S mingw-w64-%MSYS2_ARCH%-libtool && break || sleep 15; done"
36+
# Install Go deps
37+
- go get -t -v ./...
38+
39+
test_script:
40+
- go test -v ./...

appveyor.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

certstore_windows.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@ func (s *winStore) Identities() ([]Identity, error) {
112112
goto fail
113113
}
114114

115-
// maximum chain length. this is arbitrary
116-
const maxChain = 1 << 30
115+
// not sure why this isn't 1 << 29
116+
const maxPointerArray = 1 << 28
117117

118118
// rgpChain is actually an array, but we only care about the first one.
119119
simpleChain := *chainCtx.rgpChain
120-
if simpleChain.cElement < 1 || simpleChain.cElement > maxChain {
120+
if simpleChain.cElement < 1 || simpleChain.cElement > maxPointerArray {
121121
err = errors.New("bad chain")
122122
goto fail
123123
}
124124

125125
// Hacky way to get chain elements (c array) as a slice.
126-
chainElts := (*[maxChain]C.PCERT_CHAIN_ELEMENT)(unsafe.Pointer(simpleChain.rgpElement))[:simpleChain.cElement:simpleChain.cElement]
126+
chainElts := (*[maxPointerArray]C.PCERT_CHAIN_ELEMENT)(unsafe.Pointer(simpleChain.rgpElement))[:simpleChain.cElement:simpleChain.cElement]
127127

128128
// Build chain of certificates from each elt's certificate context.
129129
chain := make([]C.PCCERT_CONTEXT, len(chainElts))
@@ -654,10 +654,17 @@ func (ss securityStatus) Error() string {
654654
}
655655

656656
func stringToUTF16(s string) C.LPCWSTR {
657+
// Not sure why this isn't 1 << 30...
658+
const maxUint16Array = 1 << 29
659+
660+
if len(s) > maxUint16Array {
661+
panic("string too long")
662+
}
663+
657664
wstr := utf16.Encode([]rune(s))
658665

659666
p := C.calloc(C.size_t(len(wstr)+1), C.size_t(unsafe.Sizeof(uint16(0))))
660-
pp := (*[1 << 30]uint16)(p)
667+
pp := (*[maxUint16Array]uint16)(p)
661668
copy(pp[:], wstr)
662669

663670
return (C.LPCWSTR)(p)

0 commit comments

Comments
 (0)