Commit 9f426d3
committed
oci: cas: use blob file size as ExpectedSize
In a future patch, ExpectedSize < 0 will no longer be supported by
VerifiedReadCloser.
However, this also gives us an opportunity to add a bit of extra
hardening here -- if an attacker can write blobs to our store then they
could in theory trigger a DoS by constantly writing more bytes (or
expanding a zero section of a sparse file) if we do not have some hard
limit. The current file size is as good a limit as any (and is going to
be correct in all reasonable cases).
This also lets us avoid double-hashing blobs in the common case where
the blob size is correct (because then the VerifiedReadCloser returned
by GetVerifiedBlob() will be a no-op).
Signed-off-by: Aleksa Sarai <[email protected]>1 parent f585d05 commit 9f426d3
1 file changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
247 | 251 | | |
248 | 252 | | |
249 | 253 | | |
250 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
251 | 258 | | |
252 | 259 | | |
253 | 260 | | |
| |||
0 commit comments