Merge pull request #317 from crawford/json
configdrive: check metadata length before parsing
This commit is contained in:
commit
19ce7ac849
@ -60,7 +60,7 @@ func (cd *configDrive) FetchMetadata() (metadata datasource.Metadata, err error)
|
||||
} `json:"network_config"`
|
||||
}
|
||||
|
||||
if data, err = cd.tryReadFile(path.Join(cd.openstackVersionRoot(), "meta_data.json")); err != nil {
|
||||
if data, err = cd.tryReadFile(path.Join(cd.openstackVersionRoot(), "meta_data.json")); err != nil || len(data) == 0 {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal([]byte(data), &m); err != nil {
|
||||
|
@ -29,6 +29,10 @@ func TestFetchMetadata(t *testing.T) {
|
||||
|
||||
metadata datasource.Metadata
|
||||
}{
|
||||
{
|
||||
root: "/",
|
||||
files: test.MockFilesystem{"/openstack/latest/meta_data.json": ""},
|
||||
},
|
||||
{
|
||||
root: "/",
|
||||
files: test.MockFilesystem{"/openstack/latest/meta_data.json": `{"ignore": "me"}`},
|
||||
|
Loading…
Reference in New Issue
Block a user