content/local: validate digest before calculating path

Signed-off-by: Stephen Day <stephen.day@getcruise.com>
This commit is contained in:
Stephen Day
2020-04-09 17:20:51 -07:00
parent a31f5e46e0
commit 4615111ba2
3 changed files with 38 additions and 10 deletions

View File

@@ -329,7 +329,10 @@ func checkCopy(t checker, size int64, dst io.Writer, src io.Reader) {
}
func checkBlobPath(t *testing.T, cs content.Store, dgst digest.Digest) string {
path := cs.(*store).blobPath(dgst)
path, err := cs.(*store).blobPath(dgst)
if err != nil {
t.Fatalf("failed to calculate blob path: %v", err)
}
if path != filepath.Join(cs.(*store).root, "blobs", dgst.Algorithm().String(), dgst.Hex()) {
t.Fatalf("unexpected path: %q", path)