avoid out of bounds write in unlock_notify_wait on 64 bit platforms

While `C.sizeof_unit` is 4, we convert to a Go uint and write it to the
pointer. The Go uint is eight bytes on 64 bit platforms.

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-05-19 12:47:48 +02:00
parent 20826e87d8
commit 904664d0b0

View File

@@ -21,6 +21,7 @@ package sqlite3
extern void unlock_notify_callback(void *arg, int argc); extern void unlock_notify_callback(void *arg, int argc);
*/ */
import "C" import "C"
import ( import (
"fmt" "fmt"
"math" "math"
@@ -82,7 +83,7 @@ func unlock_notify_wait(db *C.sqlite3) C.int {
h := unt.add(c) h := unt.add(c)
defer unt.remove(h) defer unt.remove(h)
pargv := C.malloc(C.sizeof_uint) pargv := C.malloc(C.size_t(unsafe.Sizeof(uint(0))))
defer C.free(pargv) defer C.free(pargv)
argv := (*[1]uint)(pargv) argv := (*[1]uint)(pargv)