]> git.apps.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)
committerSage Weil <sage@inktank.com>
Fri, 30 May 2014 16:51:52 +0000 (09:51 -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>
src/rgw/rgw_op.cc

index 4b2e6b7e04ccc97f1b0d649f5abab6cb5fe5fcad..2069f56b9f225203d2a7dad9b5c75a4588991ca7 100644 (file)
@@ -1585,6 +1585,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));
@@ -1703,6 +1705,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);