Skip to content

Commit 246db49

Browse files
committed
cmd/cgo: panic when length too large
Fixes #53965
1 parent 176b63e commit 246db49

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/cmd/cgo/out.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,9 @@ const cBytesDef = `
16691669
// freed, such as by calling C.free (be sure to include stdlib.h
16701670
// if C.free is needed).
16711671
func _Cfunc_CBytes(b []byte) unsafe.Pointer {
1672+
if len(b) > (1<<30) {
1673+
panic("length of []byte is larger than 1<<30")
1674+
}
16721675
p := _cgo_cmalloc(uint64(len(b)))
16731676
pp := (*[1<<30]byte)(p)
16741677
copy(pp[:], b)

0 commit comments

Comments
 (0)