Skip to content

Commit c9edb37

Browse files
fix(storage): add a safety check for readhandle (#11549)
By running some tests observed that default ReadObjectSpec looks like: `read_object_spec:{bucket:"projects/_/buckets/bucket-name" object:"obj-name" read_handle:{}}` Which is not correct as we pass nil read_handle. Added an check in NewRangeReader and NewMultiRangeDownloader to only pass read_handle in read_object_spec when it is not nil. Reason: Default value of readHandle that we attach to objectHandle will be []( same as default value of byte array). In case nil read_handle is passed by user we would already be doing the slow auth hence adding the check should not be a issue in that case too.
1 parent 0bb3434 commit c9edb37

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

storage/grpc_client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ func (c *grpcStorageClient) NewMultiRangeDownloader(ctx context.Context, params
10921092
r.Generation = params.gen
10931093
}
10941094

1095-
if params.handle != nil {
1095+
if params.handle != nil && len(*params.handle) != 0 {
10961096
r.ReadHandle = &storagepb.BidiReadHandle{
10971097
Handle: *params.handle,
10981098
}
@@ -1107,7 +1107,7 @@ func (c *grpcStorageClient) NewMultiRangeDownloader(ctx context.Context, params
11071107
if err := applyCondsProto("grpcStorageClient.BidiReadObject", params.gen, params.conds, r); err != nil {
11081108
return nil, nil, err
11091109
}
1110-
if readHandle != nil {
1110+
if len(readHandle) != 0 {
11111111
req.GetReadObjectSpec().ReadHandle = &storagepb.BidiReadHandle{
11121112
Handle: readHandle,
11131113
}
@@ -1526,7 +1526,7 @@ func (c *grpcStorageClient) NewRangeReader(ctx context.Context, params *newRange
15261526
if err := applyCondsProto("gRPCReader.NewRangeReader", params.gen, params.conds, spec); err != nil {
15271527
return nil, err
15281528
}
1529-
if params.handle != nil {
1529+
if params.handle != nil && len(*params.handle) != 0 {
15301530
spec.ReadHandle = &storagepb.BidiReadHandle{
15311531
Handle: *params.handle,
15321532
}

0 commit comments

Comments
 (0)