Skip to content

Commit

Permalink
checking length on stripExcessSpaces (#1372)
Browse files Browse the repository at this point in the history
  • Loading branch information
xibz authored Jun 26, 2017
1 parent 6983621 commit 641e238
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aws/signer/v4/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ func stripExcessSpaces(headerVals []string) []string {
}
}

if stripToIdx >= 0 {
if stripToIdx >= 0 && stripToIdx < len(buf) {
// Find next double space
idx = bytes.Index(buf[stripToIdx:], doubleSpaceBytes)
if idx >= 0 {
idx += stripToIdx
Expand Down
2 changes: 2 additions & 0 deletions aws/signer/v4/v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestStripExcessHeaders(t *testing.T) {
"1 2 3",
"1 2 ",
" 1 2 ",
"12 3",
}

expected := []string{
Expand All @@ -39,6 +40,7 @@ func TestStripExcessHeaders(t *testing.T) {
"1 2 3",
"1 2",
"1 2",
"12 3",
}

newVals := stripExcessSpaces(vals)
Expand Down

0 comments on commit 641e238

Please sign in to comment.