Skip to content

Commit

Permalink
schema1: Validate descriptors in AppendReference
Browse files Browse the repository at this point in the history
If the digest is malformed, it will cause a panic when building the
manifest.

Signed-off-by: Aaron Lehmann <[email protected]>
  • Loading branch information
aaronlehmann committed Nov 30, 2016
1 parent bf27f26 commit ec5fa1f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions manifest/schema1/config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,13 @@ func (mb *configManifestBuilder) emptyTar(ctx context.Context) (digest.Digest, e

// AppendReference adds a reference to the current ManifestBuilder
func (mb *configManifestBuilder) AppendReference(d distribution.Describable) error {
// todo: verification here?
mb.descriptors = append(mb.descriptors, d.Descriptor())
descriptor := d.Descriptor()

if err := descriptor.Digest.Validate(); err != nil {
return err
}

mb.descriptors = append(mb.descriptors, descriptor)
return nil
}

Expand Down

0 comments on commit ec5fa1f

Please sign in to comment.