Skip to content

Commit d116651

Browse files
authored
Fix flex checksum nil dereference issue (#2964)
* fix nil deref bug in checksum setter * add changelog * update changelog and code comment * update comment
1 parent 8fac7d4 commit d116651

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "2e03eae0-7dff-4beb-9496-3939b6549426",
3+
"type": "bugfix",
4+
"description": "Fix nil dereference panic for operations that require checksums, but do not have an input setting for which algorithm to use.",
5+
"modules": [
6+
"service/internal/checksum"
7+
]
8+
}

service/internal/checksum/middleware_setup_context.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ func (m *setupInputContext) HandleInitialize(
4646
) (
4747
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
4848
) {
49-
if algorithm, ok := m.GetAlgorithm(in.Parameters); ok {
50-
ctx = internalcontext.SetChecksumInputAlgorithm(ctx, algorithm)
51-
return next.HandleInitialize(ctx, in)
49+
// nil check here is for operations that require checksum but do not have input algorithm setting
50+
if m.GetAlgorithm != nil {
51+
if algorithm, ok := m.GetAlgorithm(in.Parameters); ok {
52+
ctx = internalcontext.SetChecksumInputAlgorithm(ctx, algorithm)
53+
return next.HandleInitialize(ctx, in)
54+
}
5255
}
5356

5457
if m.RequireChecksum || m.RequestChecksumCalculation == aws.RequestChecksumCalculationWhenSupported {

0 commit comments

Comments
 (0)