Skip to content

Commit

Permalink
Merge pull request #5583 from ygersie/fingerprint_nilpointer
Browse files Browse the repository at this point in the history
fix nil pointer in fingerprinting AWS env leading to crash
  • Loading branch information
schmichael authored Apr 19, 2019
2 parents 54e1e07 + 77a8fda commit 8a0df40
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions client/fingerprint/env_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ func (f *EnvAWSFingerprint) Fingerprint(request *FingerprintRequest, response *F
}
for k, unique := range keys {
res, err := client.Get(metadataURL + k)
if res.StatusCode != http.StatusOK {
f.logger.Debug("could not read attribute value", "attribute", k)
continue
}
if err != nil {
// if it's a URL error, assume we're not in an AWS environment
// TODO: better way to detect AWS? Check xen virtualization?
Expand All @@ -118,6 +114,9 @@ func (f *EnvAWSFingerprint) Fingerprint(request *FingerprintRequest, response *F
}
// not sure what other errors it would return
return err
} else if res.StatusCode != http.StatusOK {
f.logger.Debug("could not read attribute value", "attribute", k)
continue
}
resp, err := ioutil.ReadAll(res.Body)
res.Body.Close()
Expand Down

0 comments on commit 8a0df40

Please sign in to comment.