-
Notifications
You must be signed in to change notification settings - Fork 170
Fix validating hash on uncompressed storage #819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix validating hash on uncompressed storage #819
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes- thanks for finding and reporting this!
@@ -352,7 +352,7 @@ func (c *diskCache) writeAndCloseFile(ctx context.Context, r io.Reader, kind cac | |||
var err error | |||
var sizeOnDisk int64 | |||
|
|||
if kind == cache.CAS && c.storageMode != casblob.Identity { | |||
if kind == cache.CAS { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this change alone sufficient (and why is the casblob.go refactoring required) ? It's hard to tell in the github UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WriteAndCose
method computed and wrote the CAS blob header (here) even when Identity
was passed, but uncompressed
expects the blobs to be plain
Co-authored-by: Mostyn Bramley-Moore <[email protected]>
This seems to have been unchecked since v2.0.0. Alternative fix to buchgr#819.
This seems to have been unchecked since v2.0.0. Alternative fix to buchgr#819.
This seems to have been unchecked since v2.0.0. Alternative fix to buchgr#819.
Sorry it took so long to get to this. I refactored your test a bit and then implemented a simpler fix which doesn't touch casblob: #826 |
When storage mode is
uncompressed
, cas blobs are not validated against their sha and accepted regardless. The validation is instead performed when usingzstd
storage mode. This refactorscasbob.WriteAndClose
to write both compressed and uncompress blobs and validate their content.