fix: when we have a proof, the body also has a metadata type byte that needs to be validated

This commit is contained in:
Derrick Hammer 2024-03-01 02:46:10 -05:00
parent f350a37e58
commit 28ff1eed48
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 12 additions and 1 deletions

View File

@ -152,7 +152,18 @@ func (m *MediaMetadata) decodeProof(dec *msgpack.Decoder) error {
m.provenPubKeys = provenPubKeys
return m.decodeMedia(msgpack.NewDecoder(bytes.NewReader(bodyBytes)))
mediaDec := msgpack.NewDecoder(bytes.NewReader(bodyBytes))
mediaByte, err := mediaDec.DecodeUint8()
if err != nil {
return err
}
if types.MetadataType(mediaByte) != types.MetadataTypeMedia {
return errors.New("Invalid metadata type")
}
return m.decodeMedia(mediaDec)
}
func (m *MediaMetadata) decodeMedia(dec *msgpack.Decoder) error {