]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: don't expose stack buffer in stringto{byte,rune}slice
authorKeith Randall <khr@golang.org>
Thu, 4 Feb 2016 21:38:38 +0000 (13:38 -0800)
committerKeith Randall <khr@golang.org>
Thu, 4 Feb 2016 23:57:10 +0000 (23:57 +0000)
commit4d02b1241738a5bd06201455a4f74a013f6c9437
tree1aa3d0d40a1d62ae81b788d40f88926324e81686
parent39304eb69d7f6117e60630452c0e037dbb555f5e
runtime: don't expose stack buffer in stringto{byte,rune}slice

When using a stack-allocated buffer for the result, don't
expose the uninitialized portion of it by restricting its
capacity to its length.

The other option is to zero the portion between len and cap.
That seems like more work, but might be worth it if the caller
then appends some stuff to the result.  But this close to 1.6,
I'm inclined to do the simplest fix possible.

Fixes #14232

Change-Id: I21c50d3cda02fd2df4d60ba5e2cfe2efe272f333
Reviewed-on: https://go-review.googlesource.com/19231
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/string.go
src/runtime/string_test.go