fix: authenticate SSE-C keys on zero-byte reads

Unseal supplied SSE-C and copy-source keys after range and request preconditions when a zero-byte read cannot build a decryptor. Preserve internal no-decryption, replication, restore, and absent-header reads.

Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
Feng Ruohang
2026-08-29 17:26:09 +08:00
parent 5732930102
commit b73581b05d
3 changed files with 256 additions and 2 deletions
+12 -2
View File
@@ -266,9 +266,19 @@ func (er erasureObjects) GetObjectNInfo(ctx context.Context, bucket, object stri
ObjInfo: objInfo,
}, err
}
// Zero byte objects don't even need to further initialize pipes etc.
return NewGetObjectReaderFromReader(bytes.NewReader(nil), objInfo, opts)
gr, err = NewGetObjectReaderFromReader(bytes.NewReader(nil), objInfo, opts)
if err != nil {
return gr, err
}
// With no data, the reader above cannot authenticate an SSE-C key the
// way NewGetObjectReader does. Check it after the preconditions so zero
// and non-zero reads preserve the same error ordering.
if err := checkSSECReadKey(h, objInfo, opts); err != nil {
gr.Close()
return nil, err
}
return gr, nil
}
if objInfo.IsRemote() {