summaryrefslogtreecommitdiffstats
path: root/modules/http2
diff options
context:
space:
mode:
authorStefan Eissing <icing@apache.org>2017-08-04 13:03:08 +0200
committerStefan Eissing <icing@apache.org>2017-08-04 13:03:08 +0200
commita2f0c639f3af9a8f1546f5adf6c7e727603079fe (patch)
tree5fb49eb83f893d4b2c437df766cee7c882add9c4 /modules/http2
parentmod_http2: non-dev version for backport (diff)
downloadapache2-a2f0c639f3af9a8f1546f5adf6c7e727603079fe.tar.xz
apache2-a2f0c639f3af9a8f1546f5adf6c7e727603079fe.zip
bumping version, removing some unused code, fixes in base64url from mod_md
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1804096 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/http2')
-rw-r--r--modules/http2/h2_util.c81
-rw-r--r--modules/http2/h2_util.h9
-rw-r--r--modules/http2/h2_version.h2
3 files changed, 22 insertions, 70 deletions
diff --git a/modules/http2/h2_util.c b/modules/http2/h2_util.c
index e1879cb200..47dcdf56b2 100644
--- a/modules/http2/h2_util.c
+++ b/modules/http2/h2_util.c
@@ -112,6 +112,8 @@ void h2_util_camel_case_header(char *s, size_t len)
}
}
+/* base64 url encoding ****************************************************************************/
+
static const int BASE64URL_UINT6[] = {
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0 */
@@ -174,6 +176,7 @@ apr_size_t h2_util_base64url_decode(const char **decoded, const char *encoded,
n = ((BASE64URL_UINT6[ e[mlen+0] ] << 18) +
(BASE64URL_UINT6[ e[mlen+1] ] << 12));
*d++ = n >> 16;
+ remain = 1;
break;
case 3:
n = ((BASE64URL_UINT6[ e[mlen+0] ] << 18) +
@@ -181,6 +184,7 @@ apr_size_t h2_util_base64url_decode(const char **decoded, const char *encoded,
(BASE64URL_UINT6[ e[mlen+2] ] << 6));
*d++ = n >> 16;
*d++ = n >> 8 & 0xffu;
+ remain = 2;
break;
default: /* do nothing */
break;
@@ -189,78 +193,35 @@ apr_size_t h2_util_base64url_decode(const char **decoded, const char *encoded,
}
const char *h2_util_base64url_encode(const char *data,
- apr_size_t len, apr_pool_t *pool)
+ apr_size_t dlen, apr_pool_t *pool)
{
- apr_size_t mlen = ((len+2)/3)*3;
- apr_size_t slen = (mlen/3)*4;
- apr_size_t i;
+ long i, len = (int)dlen;
+ apr_size_t slen = ((dlen+2)/3)*4 + 1; /* 0 terminated */
const unsigned char *udata = (const unsigned char*)data;
- char *enc, *p = apr_pcalloc(pool, slen+1); /* 0 terminated */
+ char *enc, *p = apr_pcalloc(pool, slen);
enc = p;
- for (i = 0; i < mlen; i+= 3) {
+ for (i = 0; i < len-2; i+= 3) {
*p++ = BASE64URL_CHARS[ (udata[i] >> 2) & 0x3fu ];
- *p++ = BASE64URL_CHARS[ ((udata[i] << 4) +
- ((i+1 < len)? (udata[i+1] >> 4) : 0)) & 0x3fu ];
- *p++ = BASE64URL_CHARS[ ((udata[i+1] << 2) +
- ((i+2 < len)? (udata[i+2] >> 6) : 0)) & 0x3fu ];
- if (i+2 < len) {
- *p++ = BASE64URL_CHARS[ udata[i+2] & 0x3fu ];
- }
+ *p++ = BASE64URL_CHARS[ ((udata[i] << 4) + (udata[i+1] >> 4)) & 0x3fu ];
+ *p++ = BASE64URL_CHARS[ ((udata[i+1] << 2) + (udata[i+2] >> 6)) & 0x3fu ];
+ *p++ = BASE64URL_CHARS[ udata[i+2] & 0x3fu ];
}
- return enc;
-}
-
-int h2_util_contains_token(apr_pool_t *pool, const char *s, const char *token)
-{
- char *c;
- if (s) {
- if (!apr_strnatcasecmp(s, token)) { /* the simple life */
- return 1;
- }
-
- for (c = ap_get_token(pool, &s, 0); c && *c;
- c = *s? ap_get_token(pool, &s, 0) : NULL) {
- if (!apr_strnatcasecmp(c, token)) { /* seeing the token? */
- return 1;
- }
- while (*s++ == ';') { /* skip parameters */
- ap_get_token(pool, &s, 0);
- }
- if (*s++ != ',') { /* need comma separation */
- return 0;
- }
+ if (i < len) {
+ *p++ = BASE64URL_CHARS[ (udata[i] >> 2) & 0x3fu ];
+ if (i == (len - 1)) {
+ *p++ = BASE64URL_CHARS[ (udata[i] << 4) & 0x3fu ];
}
- }
- return 0;
-}
-
-const char *h2_util_first_token_match(apr_pool_t *pool, const char *s,
- const char *tokens[], apr_size_t len)
-{
- char *c;
- apr_size_t i;
- if (s && *s) {
- for (c = ap_get_token(pool, &s, 0); c && *c;
- c = *s? ap_get_token(pool, &s, 0) : NULL) {
- for (i = 0; i < len; ++i) {
- if (!apr_strnatcasecmp(c, tokens[i])) {
- return tokens[i];
- }
- }
- while (*s++ == ';') { /* skip parameters */
- ap_get_token(pool, &s, 0);
- }
- if (*s++ != ',') { /* need comma separation */
- return 0;
- }
+ else {
+ *p++ = BASE64URL_CHARS[ ((udata[i] << 4) + (udata[i+1] >> 4)) & 0x3fu ];
+ *p++ = BASE64URL_CHARS[ (udata[i+1] << 2) & 0x3fu ];
}
}
- return NULL;
+ *p++ = '\0';
+ return enc;
}
-
/*******************************************************************************
* ihash - hash for structs with int identifier
******************************************************************************/
diff --git a/modules/http2/h2_util.h b/modules/http2/h2_util.h
index b2c25f69cc..01ccccd765 100644
--- a/modules/http2/h2_util.h
+++ b/modules/http2/h2_util.h
@@ -337,15 +337,6 @@ unsigned char h2_log2(int n);
*/
apr_size_t h2_util_table_bytes(apr_table_t *t, apr_size_t pair_extra);
-/**
- * Return != 0 iff the string s contains the token, as specified in
- * HTTP header syntax, rfc7230.
- */
-int h2_util_contains_token(apr_pool_t *pool, const char *s, const char *token);
-
-const char *h2_util_first_token_match(apr_pool_t *pool, const char *s,
- const char *tokens[], apr_size_t len);
-
/** Match a header value against a string constance, case insensitive */
#define H2_HD_MATCH_LIT(l, name, nlen) \
((nlen == sizeof(l) - 1) && !apr_strnatcasecmp(l, name))
diff --git a/modules/http2/h2_version.h b/modules/http2/h2_version.h
index c5e356e354..50e9abc03f 100644
--- a/modules/http2/h2_version.h
+++ b/modules/http2/h2_version.h
@@ -26,7 +26,7 @@
* @macro
* Version number of the http2 module as c string
*/
-#define MOD_HTTP2_VERSION "1.10.10"
+#define MOD_HTTP2_VERSION "1.10.11-DEV"
/**
* @macro