Skip to content

Commit

Permalink
Fix flex checksum nil dereference issue (#2964)
Browse files Browse the repository at this point in the history
* fix nil deref bug in checksum setter

* add changelog

* update changelog and code comment

* update comment
  • Loading branch information
wty-Bryant authored Jan 16, 2025
1 parent 8fac7d4 commit d116651
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changelog/2e03eae07dff4beb94963939b6549426.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "2e03eae0-7dff-4beb-9496-3939b6549426",
"type": "bugfix",
"description": "Fix nil dereference panic for operations that require checksums, but do not have an input setting for which algorithm to use.",
"modules": [
"service/internal/checksum"
]
}
9 changes: 6 additions & 3 deletions service/internal/checksum/middleware_setup_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ func (m *setupInputContext) HandleInitialize(
) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
if algorithm, ok := m.GetAlgorithm(in.Parameters); ok {
ctx = internalcontext.SetChecksumInputAlgorithm(ctx, algorithm)
return next.HandleInitialize(ctx, in)
// nil check here is for operations that require checksum but do not have input algorithm setting
if m.GetAlgorithm != nil {
if algorithm, ok := m.GetAlgorithm(in.Parameters); ok {
ctx = internalcontext.SetChecksumInputAlgorithm(ctx, algorithm)
return next.HandleInitialize(ctx, in)
}
}

if m.RequireChecksum || m.RequestChecksumCalculation == aws.RequestChecksumCalculationWhenSupported {
Expand Down

0 comments on commit d116651

Please sign in to comment.