diff options
author | Quentin <quentin@deuxfleurs.fr> | 2020-11-22 11:14:46 +0100 |
---|---|---|
committer | Quentin <quentin@deuxfleurs.fr> | 2020-11-22 11:14:46 +0100 |
commit | 17dc610f8a2e8e8d15b427d0c4f38dca498f798f (patch) | |
tree | a9a0c9483c5db4ee826ed6ca64c5eb283c73a28f | |
parent | 435d5f9205d2dd272b5ea58690490ad4712954d7 (diff) | |
download | garage-17dc610f8a2e8e8d15b427d0c4f38dca498f798f.tar.gz garage-17dc610f8a2e8e8d15b427d0c4f38dca498f798f.zip |
Also check hash for < 3KB filesbug/checksums
-rw-r--r-- | src/api/s3_put.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/api/s3_put.rs b/src/api/s3_put.rs index 54fa3200..a528720d 100644 --- a/src/api/s3_put.rs +++ b/src/api/s3_put.rs @@ -51,6 +51,20 @@ pub async fn handle_put( let md5sum_arr = md5sum.finalize(); let md5sum_hex = hex::encode(md5sum_arr); + let mut sha256sum = Sha256::new(); + sha256sum.input(&first_block[..]); + let sha256sum_arr = sha256sum.result(); + let mut hash = [0u8; 32]; + hash.copy_from_slice(&sha256sum_arr[..]); + let sha256sum_hash = Hash::from(hash); + + ensure_checksum_matches( + md5sum_arr.as_slice(), + sha256sum_hash, + content_md5.as_deref(), + content_sha256, + )?; + object_version.state = ObjectVersionState::Complete(ObjectVersionData::Inline( ObjectVersionMeta { headers, |