summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2018-10-06 18:31:47 +0000
committertb <>2018-10-06 18:31:47 +0000
commit6f3a7bc27fb7692e32371ed2bac7b2ba250bcd09 (patch)
treeeca67f7047260e938dd07961419e17a772638498 /src
parent5a2b8d5c5a10251aaf5eb5616d46b8e833a22e15 (diff)
downloadopenbsd-6f3a7bc27fb7692e32371ed2bac7b2ba250bcd09.tar.gz
openbsd-6f3a7bc27fb7692e32371ed2bac7b2ba250bcd09.tar.bz2
openbsd-6f3a7bc27fb7692e32371ed2bac7b2ba250bcd09.zip
make sure all CStrings are freed
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
index 7ec02a8f32..1243be6d60 100644
--- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go
+++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
@@ -1,4 +1,4 @@
1/* $OpenBSD: wycheproof.go,v 1.79 2018/10/06 14:23:08 tb Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.80 2018/10/06 18:31:47 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
@@ -1145,18 +1145,21 @@ func runDSATestGroup(algorithm string, wtg *wycheproofTestGroupDSA) bool {
1145 if C.BN_hex2bn(&bnG, wg) == 0 { 1145 if C.BN_hex2bn(&bnG, wg) == 0 {
1146 log.Fatal("Failed to decode g") 1146 log.Fatal("Failed to decode g")
1147 } 1147 }
1148 C.free(unsafe.Pointer(wg))
1148 1149
1149 var bnP *C.BIGNUM 1150 var bnP *C.BIGNUM
1150 wp := C.CString(wtg.Key.P) 1151 wp := C.CString(wtg.Key.P)
1151 if C.BN_hex2bn(&bnP, wp) == 0 { 1152 if C.BN_hex2bn(&bnP, wp) == 0 {
1152 log.Fatal("Failed to decode p") 1153 log.Fatal("Failed to decode p")
1153 } 1154 }
1155 C.free(unsafe.Pointer(wp))
1154 1156
1155 var bnQ *C.BIGNUM 1157 var bnQ *C.BIGNUM
1156 wq := C.CString(wtg.Key.Q) 1158 wq := C.CString(wtg.Key.Q)
1157 if C.BN_hex2bn(&bnQ, wq) == 0 { 1159 if C.BN_hex2bn(&bnQ, wq) == 0 {
1158 log.Fatal("Failed to decode q") 1160 log.Fatal("Failed to decode q")
1159 } 1161 }
1162 C.free(unsafe.Pointer(wq))
1160 1163
1161 ret := C.DSA_set0_pqg(dsa, bnP, bnQ, bnG) 1164 ret := C.DSA_set0_pqg(dsa, bnP, bnQ, bnG)
1162 if ret != 1 { 1165 if ret != 1 {
@@ -1168,6 +1171,7 @@ func runDSATestGroup(algorithm string, wtg *wycheproofTestGroupDSA) bool {
1168 if C.BN_hex2bn(&bnY, wy) == 0 { 1171 if C.BN_hex2bn(&bnY, wy) == 0 {
1169 log.Fatal("Failed to decode y") 1172 log.Fatal("Failed to decode y")
1170 } 1173 }
1174 C.free(unsafe.Pointer(wy))
1171 1175
1172 ret = C.DSA_set0_key(dsa, bnY, nil) 1176 ret = C.DSA_set0_key(dsa, bnY, nil)
1173 if ret != 1 { 1177 if ret != 1 {
@@ -1588,14 +1592,14 @@ func encodeECDSAWebCryptoSig(wtSig string) (*C.uchar, C.int) {
1588 sigLen := len(wtSig) 1592 sigLen := len(wtSig)
1589 r := C.CString(wtSig[:sigLen/2]) 1593 r := C.CString(wtSig[:sigLen/2])
1590 s := C.CString(wtSig[sigLen/2:]) 1594 s := C.CString(wtSig[sigLen/2:])
1595 defer C.free(unsafe.Pointer(r))
1596 defer C.free(unsafe.Pointer(s))
1591 if C.BN_hex2bn(&cSig.r, r) == 0 { 1597 if C.BN_hex2bn(&cSig.r, r) == 0 {
1592 return nil, 0 1598 return nil, 0
1593 } 1599 }
1594 if C.BN_hex2bn(&cSig.s, s) == 0 { 1600 if C.BN_hex2bn(&cSig.s, s) == 0 {
1595 return nil, 0 1601 return nil, 0
1596 } 1602 }
1597 C.free(unsafe.Pointer(r))
1598 C.free(unsafe.Pointer(s))
1599 1603
1600 derLen := C.i2d_ECDSA_SIG(cSig, nil) 1604 derLen := C.i2d_ECDSA_SIG(cSig, nil)
1601 if derLen == 0 { 1605 if derLen == 0 {