ret = ceph_unarmor(supplied_md5_bin, &supplied_md5_bin[CEPH_CRYPTO_MD5_DIGESTSIZE + 1],
supplied_md5_b64, supplied_md5_b64 + strlen(supplied_md5_b64));
RGW_LOG(15) << "ceph_armor ret=" << ret << dendl;
+ if (ret < 0) {
+ goto done;
+ }
if (ret != CEPH_CRYPTO_MD5_DIGESTSIZE) {
ret = -ERR_INVALID_DIGEST;
goto done;
return parse_rfc850(s, t) || parse_asctime(s, t) || parse_rfc1123(s, t);
}
+static inline bool is_base64(unsigned char c) {
+ return (isalnum(c) || (c == '+') || (c == '/'));
+}
+
/*
* get the header authentication information required to
* compute a request's signature
dest.append("\n");
const char *md5 = s->env->get("HTTP_CONTENT_MD5");
- if (md5)
+ if (md5) {
+ for (const char *p = md5; *p; p++) {
+ if (!is_base64(*p)) {
+ RGW_LOG(0) << "bad content-md5 provided (not base64), aborting request" << dendl;
+ return false;
+ }
+ }
dest.append(md5);
+ }
dest.append("\n");
const char *type = s->env->get("CONTENT_TYPE");