mirror of https://github.com/golang/go.git
runtime: fix buffer overflow in make(chan)
On 32-bits one can arrange make(chan) params so that the chan buffer gives you access to whole memory. LGTM=r R=golang-codereviews, r CC=bradfitz, golang-codereviews, iant, khr https://golang.org/cl/50250045
This commit is contained in:
parent
ce884036d2
commit
d409e44cfb
|
|
@ -104,7 +104,7 @@ runtime·makechan_c(ChanType *t, int64 hint)
|
|||
if((sizeof(*c)%MAXALIGN) != 0 || elem->align > MAXALIGN)
|
||||
runtime·throw("makechan: bad alignment");
|
||||
|
||||
if(hint < 0 || (intgo)hint != hint || (elem->size > 0 && hint > MaxMem / elem->size))
|
||||
if(hint < 0 || (intgo)hint != hint || (elem->size > 0 && hint > (MaxMem - sizeof(*c)) / elem->size))
|
||||
runtime·panicstring("makechan: size out of range");
|
||||
|
||||
// allocate memory in one call
|
||||
|
|
|
|||
Loading…
Reference in New Issue