| 1 |
Fromscip-debian debian golang-github-google-go-pkcs11 0.3.0+dfsg-3 golang-github-google-go-pkcs11/patches/`use-uint-for-32-bit-builds.patch`#From.: Maytham Alsudany <[email protected]scip-debian . . . identity/`[email protected]`.> |
| 2 |
Descriptionscip-debian debian golang-github-google-go-pkcs11 0.3.0+dfsg-3 golang-github-google-go-pkcs11/patches/`use-uint-for-32-bit-builds.patch`#Description.: use uint for 32-bit builds |
| 3 |
C.malloc accepts C.ulong in 64-bit builds, but C.uint in 32-bit builds. |
| 4 |
This patch ensures the correct type is passed to C.malloc. |
| 5 |
|
| 6 |
--- a/pkcs11/pkcs11.goscip-debian debian golang-github-google-go-pkcs11 0.3.0+dfsg-3 golang-github-google-go-pkcs11/upstream/`pkcs11/pkcs11.go`: |
| 7 |
+++ b/pkcs11/pkcs11.goscip-debian debian golang-github-google-go-pkcs11 0.3.0+dfsg-3 golang-github-google-go-pkcs11/upstream/`pkcs11/pkcs11.go`: |
| 8 |
@@ -297,7 +297,7 @@ |
| 9 |
// |
| 10 |
// This method also returns a function to free the allocated C memory. |
| 11 |
func ckCString(s string) (cstring *C.CK_UTF8CHAR, free func()) { |
| 12 |
|
| 13 |
+ b := (*C.CK_UTF8CHAR)(C.malloc(C.sizeof_CK_UTF8CHAR * malloc_arg(len(s)))) |
| 14 |
bs := unsafe.Slice(b, len(s)) |
| 15 |
for i, c := range []byte(s) { |
| 16 |
bs[i] = C.CK_UTF8CHAR(c) |
| 17 |
@@ -1016,7 +1016,7 @@ |
| 18 |
} |
| 19 |
n := attrs[0].ulValueLen |
| 20 |
|
| 21 |
|
| 22 |
+ cLabel := (*C.CK_UTF8CHAR)(C.malloc(malloc_arg(n))) |
| 23 |
defer C.free(unsafe.Pointer(cLabel)) |
| 24 |
attrs[0].pValue = C.CK_VOID_PTR(cLabel) |
| 25 |
|
| 26 |
@@ -1097,11 +1097,11 @@ |
| 27 |
return nil, fmt.Errorf("no public exponent returned") |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
+ cN := (C.CK_VOID_PTR)(C.malloc(malloc_arg(attrs[0].ulValueLen) * C.sizeof_CK_BYTE)) |
| 32 |
defer C.free(unsafe.Pointer(cN)) |
| 33 |
attrs[0].pValue = cN |
| 34 |
|
| 35 |
|
| 36 |
+ cE := (C.CK_VOID_PTR)(C.malloc(malloc_arg(attrs[1].ulValueLen))) |
| 37 |
defer C.free(unsafe.Pointer(cE)) |
| 38 |
attrs[1].pValue = cE |
| 39 |
|
| 40 |
@@ -1134,11 +1134,11 @@ |
| 41 |
return nil, fmt.Errorf("no ec point available") |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
+ cParam := (C.CK_VOID_PTR)(C.malloc(malloc_arg(attrs[0].ulValueLen))) |
| 46 |
defer C.free(unsafe.Pointer(cParam)) |
| 47 |
attrs[0].pValue = cParam |
| 48 |
|
| 49 |
|
| 50 |
+ cPoint := (C.CK_VOID_PTR)(C.malloc(malloc_arg(attrs[1].ulValueLen))) |
| 51 |
defer C.free(unsafe.Pointer(cPoint)) |
| 52 |
attrs[1].pValue = cPoint |
| 53 |
|
| 54 |
@@ -1437,7 +1437,7 @@ |
| 55 |
if n == 0 { |
| 56 |
return nil, fmt.Errorf("certificate value not present") |
| 57 |
} |
| 58 |
|
| 59 |
+ cRaw := (C.CK_VOID_PTR)(C.malloc(malloc_arg(n))) |
| 60 |
defer C.free(unsafe.Pointer(cRaw)) |
| 61 |
|
| 62 |
attrs[0].pValue = cRaw |
| 63 |
--- /dev/nullscip-debian debian golang-github-google-go-pkcs11 0.3.0+dfsg-3 golang-github-google-go-pkcs11/upstream/`/dev/null`: |
| 64 |
+++ b/pkcs11/32bit.goscip-debian debian golang-github-google-go-pkcs11 0.3.0+dfsg-3 golang-github-google-go-pkcs11/upstream/`pkcs11/32bit.go`: |
| 65 |
@@ -0,0 +1,9 @@ |
| 66 |
+//go:build 386 || amd64p32 || arm || armbe || mips || mipsle || mips64p32 || mips64p32le || ppc || riscv || s390 || sparc |
| 67 |
+ |
| 68 |
+package pkcs11 |
| 69 |
+ |
| 70 |
+import "C" |
| 71 |
+ |
| 72 |
+func malloc_arg[T int | C.uint | C.ulong](arg T) C.uint { |
| 73 |
+ return C.uint(arg) |
| 74 |
+} |
| 75 |
--- /dev/null |
| 76 |
+++ b/pkcs11/64bit.goscip-debian debian golang-github-google-go-pkcs11 0.3.0+dfsg-3 golang-github-google-go-pkcs11/upstream/`pkcs11/64bit.go`: |
| 77 |
@@ -0,0 +1,9 @@ |
| 78 |
+//go:build !(386 || amd64p32 || arm || armbe || mips || mipsle || mips64p32 || mips64p32le || ppc || riscv || s390 || sparc) |
| 79 |
+ |
| 80 |
+package pkcs11 |
| 81 |
+ |
| 82 |
+import "C" |
| 83 |
+ |
| 84 |
+func malloc_arg[T int | C.uint | C.ulong](arg T) C.ulong { |
| 85 |
+ return C.ulong(arg) |
| 86 |
+} |