Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
Safely handle records without ResourceRecords
Browse files Browse the repository at this point in the history
Always check the length of ResourceRecords before trying to index.

Fix #87
  • Loading branch information
mikkeloscar committed Feb 24, 2017
1 parent c1eda17 commit fbdce6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion consumers/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (a *awsConsumer) recordInfo(records []*route53.ResourceRecordSet) map[strin
groupIDMap := map[string]string{} //maps dns to group ID

for _, record := range records {
if (aws.StringValue(record.Type)) == "TXT" {
if aws.StringValue(record.Type) == "TXT" && len(record.ResourceRecords) > 0 {
groupIDMap[aws.StringValue(record.Name)] = aws.StringValue(record.ResourceRecords[0].Value)
} else {
if _, exist := groupIDMap[aws.StringValue(record.Name)]; !exist {
Expand Down
5 changes: 5 additions & 0 deletions consumers/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ func TestRecordInfo(t *testing.T) {
},
},
},
&route53.ResourceRecordSet{
Type: aws.String("TXT"),
Name: aws.String("test.example.com."),
ResourceRecords: nil,
},
}
recordInfoMap := client.recordInfo(records)
if len(recordInfoMap) != 1 {
Expand Down

0 comments on commit fbdce6b

Please sign in to comment.