From 4754ab6c4b9c88b459a8e7df6916e69b30b32558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Gul=C3=A1csi?= Date: Sat, 18 Jul 2015 21:42:16 +0200 Subject: [PATCH] pkg/blobserver/diskpacked: fail earlier in StreamBlobs As Miki Habryn suggested at https://groups.google.com/forum/#!topic/camlistore/WmUyUWMfZx0%5B1-25%5D Change-Id: Ib910e5bcfa7eb33360f7b5e1085bd9bb1f0e9e6a --- pkg/blobserver/diskpacked/diskpacked.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/blobserver/diskpacked/diskpacked.go b/pkg/blobserver/diskpacked/diskpacked.go index 5d24b2eaf..c889f8301 100644 --- a/pkg/blobserver/diskpacked/diskpacked.go +++ b/pkg/blobserver/diskpacked/diskpacked.go @@ -611,6 +611,11 @@ func (s *storage) StreamBlobs(ctx context.Context, dest chan<- blobserver.BlobAn continue } + ref, ok := blob.ParseBytes(digest) + if !ok { + return fmt.Errorf("diskpacked: Invalid blobref %q", digest) + } + // Finally, read and send the blob. // TODO: remove this allocation per blob. We can make one instead @@ -624,10 +629,6 @@ func (s *storage) StreamBlobs(ctx context.Context, dest chan<- blobserver.BlobAn return err } offset += int64(size) - ref, ok := blob.ParseBytes(digest) - if !ok { - return fmt.Errorf("diskpacked: Invalid blobref %q", digest) - } newReader := func() readerutil.ReadSeekCloser { return newReadSeekNopCloser(bytes.NewReader(data)) }