diff options
author | Eric Wong <normalperson@yhbt.net> | 2012-01-21 10:11:47 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-01-21 10:11:47 +0000 |
commit | b956756cafe87eaa1ad9ca7cc6494d34a7cc4deb (patch) | |
tree | a9432b42661145114bea28a1c1b2205b41618de4 /http_common.rl | |
parent | 6ab213e3b250c634cc98ef92f5dd5b70f0b991ed (diff) | |
download | cmogstored-b956756cafe87eaa1ad9ca7cc6494d34a7cc4deb.tar.gz |
This means we'll eventually be able to reject uploads if the Content-MD5 trailer doesn't match the contents of the upload.
Diffstat (limited to 'http_common.rl')
-rw-r--r-- | http_common.rl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/http_common.rl b/http_common.rl index b2ccd03..cb5bc8b 100644 --- a/http_common.rl +++ b/http_common.rl @@ -13,6 +13,19 @@ header_value = (any -- CTL)*; sep = LWS+|LWS*"\r\n"LWS+; b64_val = ([a-zA-Z0-9/+]{22}) > { http->tmp_tip = to_u16(fpc - buf); } - "=="; # TODO - content_md5 = "Content-MD5:"i sep b64_val eor; + "==" + eor > { + uint16_t tmp_end = to_u16(fpc - buf); + char *in = buf + http->tmp_tip; + size_t inlen = tmp_end - http->tmp_tip; + char *out = (char *)http->expect_md5; + size_t outlen = sizeof(http->expect_md5); + bool rc; + + rc = base64_decode_ctx(NULL, in, inlen, out, &outlen); + assert(rc == true && outlen == 16 + && "base64_decoder broke for HTTP"); + http->has_expect_md5 = 1; + }; + content_md5 = "Content-MD5:"i sep b64_val; }%% |