Create copy of buffer for SignedManifest.Raw

Without this copy, the buffer may be re-used in the json package, causing
missing or corrupted content for the long-lived SignedManifest object. By
creating a new buffer, owned by the SignedManifest object, the content remains
stable.
This commit is contained in:
Stephen J Day 2014-12-01 15:57:05 -08:00
parent f497bceffa
commit 98f5f30e75

View file

@ -174,7 +174,8 @@ func (sm *SignedManifest) UnmarshalJSON(b []byte) error {
} }
sm.Manifest = manifest sm.Manifest = manifest
sm.Raw = b sm.Raw = make([]byte, len(b), len(b))
copy(sm.Raw, b)
return nil return nil
} }