From 9c56c86bdac6bcb8e76c3f04e7d393e4eaadd721 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 23 May 2014 14:58:54 -0700 Subject: [PATCH] rgw: calc md5 and compare if user provided appropriate header Fixes: #8436 Backport: firefly This was broken in ddc2e1a8e39a5c6b9b224c3eebd1c0e762ca5782. The fix resurrects and old check that was dropped. Signed-off-by: Yehuda Sadeh Reviewed-by: Sage Weil --- src/rgw/rgw_op.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 4b2e6b7e04c..2069f56b9f2 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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);