Skip to content

Commit

Permalink
Merge pull request #60 from segmentio/fix-null-pointer-panic
Browse files Browse the repository at this point in the history
guard against null description pointers
  • Loading branch information
dfuentes authored Dec 22, 2017
2 parents bc7ee45 + 23190d1 commit 0340c27
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions store/ssmstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ func (s *SSMStore) readVersion(id SecretId, version int) (Secret, error) {
}

for _, history := range resp.Parameters {
thisVersion, _ := strconv.Atoi(*history.Description)
thisVersion := 0
if history.Description != nil {
thisVersion, _ = strconv.Atoi(*history.Description)
}
if thisVersion == version {
return Secret{
Value: history.Value,
Expand Down Expand Up @@ -268,7 +271,7 @@ func (s *SSMStore) List(service string, includeValues bool) ([]Secret, error) {
},
},
MaxResults: aws.Int64(50),
NextToken: nextToken,
NextToken: nextToken,
}
} else {
describeParametersInput = &ssm.DescribeParametersInput{
Expand All @@ -279,7 +282,7 @@ func (s *SSMStore) List(service string, includeValues bool) ([]Secret, error) {
},
},
MaxResults: aws.Int64(50),
NextToken: nextToken,
NextToken: nextToken,
}
}

Expand Down Expand Up @@ -353,7 +356,10 @@ func (s *SSMStore) History(id SecretId) ([]ChangeEvent, error) {
for _, history := range resp.Parameters {
// Disregard error here, if Atoi fails (secret created outside of
// Chamber), then we use version 0
version, _ := strconv.Atoi(*history.Description)
version := 0
if history.Description != nil {
version, _ = strconv.Atoi(*history.Description)
}
events = append(events, ChangeEvent{
Type: getChangeType(version),
Time: *history.LastModifiedDate,
Expand Down Expand Up @@ -401,7 +407,10 @@ func basePath(key string) string {
}

func parameterMetaToSecretMeta(p *ssm.ParameterMetadata) SecretMetadata {
version, _ := strconv.Atoi(*p.Description)
version := 0
if p.Description != nil {
version, _ = strconv.Atoi(*p.Description)
}
return SecretMetadata{
Created: *p.LastModifiedDate,
CreatedBy: *p.LastModifiedUser,
Expand Down

0 comments on commit 0340c27

Please sign in to comment.