golang/src/database/sql
Damien Neil c23579f031 database/sql: avoid clobbering driver-owned memory in RawBytes
Depending on the query, a RawBytes can contain memory owned by the
driver or by database/sql:

If the driver provides the column as a []byte,
RawBytes aliases that []byte.

If the driver provides the column as any other type,
RawBytes contains memory allocated by database/sql.
Prior to this CL, Rows.Scan will reuse existing capacity in a
RawBytes to permit a single allocation to be reused across rows.

When a RawBytes is reused across queries, this can result
in database/sql writing to driver-owned memory.

Add a buffer to Rows to store RawBytes data, and reuse this
buffer across calls to Rows.Scan.

Fixes #65201

Change-Id: Iac640174c7afa97eeb39496f47dec202501b2483
Reviewed-on: https://go-review.googlesource.com/c/go/+/557917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-10 20:23:22 +00:00
..
driver database/sql: wrap errors with %w in driverArgsConnLocked 2024-02-27 16:30:20 +00:00
convert.go database/sql: avoid clobbering driver-owned memory in RawBytes 2024-04-10 20:23:22 +00:00
convert_test.go database/sql: avoid clobbering driver-owned memory in RawBytes 2024-04-10 20:23:22 +00:00
ctxutil.go std: remove unused bits of code all over the place 2019-09-02 12:57:37 +00:00
doc.txt database/sql: fix typo in comment 2024-03-22 06:48:08 +00:00
example_cli_test.go all: fix some lint issues 2022-05-08 17:27:54 +00:00
example_service_test.go database/sql: add error check 2024-02-28 20:21:26 +00:00
example_test.go database/sql: fix incorrect function name in example_test 2020-04-28 14:05:09 +00:00
fakedb_test.go database/sql: use slices to simplify the code 2024-04-01 12:38:07 +00:00
sql.go database/sql: avoid clobbering driver-owned memory in RawBytes 2024-04-10 20:23:22 +00:00
sql_test.go database/sql: avoid clobbering driver-owned memory in RawBytes 2024-04-10 20:23:22 +00:00