]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: calc md5 and compare if user provided appropriate header
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 23 May 2014 21:58:54 +0000 (14:58 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 6 Aug 2014 18:32:03 +0000 (11:32 -0700)
Fixes: #8436
Backport: firefly

This was broken in ddc2e1a8e39a5c6b9b224c3eebd1c0e762ca5782. The fix
resurrects and old check that was dropped.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 9c56c86bdac6bcb8e76c3f04e7d393e4eaadd721)

src/rgw/rgw_op.cc

index 3c967664cca4193e83fcf1e0211afe2f54786e8a..5bdbb9d317731faab63c8b6b7ef6fcff1cdddc22 100644 (file)
@@ -1436,6 +1436,8 @@ void RGWPutObj::execute()
     goto done;
 
   if (supplied_md5_b64) {
+    need_calc_md5 = true;
+
     ldout(s->cct, 15) << "supplied_md5_b64=" << supplied_md5_b64 << dendl;
     ret = ceph_unarmor(supplied_md5_bin, &supplied_md5_bin[CEPH_CRYPTO_MD5_DIGESTSIZE + 1],
                        supplied_md5_b64, supplied_md5_b64 + strlen(supplied_md5_b64));
@@ -1539,6 +1541,11 @@ void RGWPutObj::execute()
 
     buf_to_hex(m, CEPH_CRYPTO_MD5_DIGESTSIZE, calc_md5);
     etag = calc_md5;
+
+    if (supplied_md5_b64 && strcmp(calc_md5, supplied_md5)) {
+      ret = -ERR_BAD_DIGEST;
+      goto done;
+    }
   }
 
   policy.encode(aclbl);