This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch 9.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 92f729f5edaa17fa69355216da6c71ba5ea8de5b Author: Masaori Koshiba <masa...@apache.org> AuthorDate: Fri Oct 29 09:34:12 2021 +0900 Check length before search accept-encoding header (#8475) (cherry picked from commit 02b17dbe3cff71ffd31577d872e077531124d207) --- plugins/stats_over_http/stats_over_http.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/stats_over_http/stats_over_http.c b/plugins/stats_over_http/stats_over_http.c index 3d348c9..7ab65d5 100644 --- a/plugins/stats_over_http/stats_over_http.c +++ b/plugins/stats_over_http/stats_over_http.c @@ -61,6 +61,10 @@ /* global holding the path used for access to this JSON data */ #define DEFAULT_URL_PATH "_stats" +// TODO: replace with TS_HTTP_* when BROTLI is supported +#define HTTP_VALUE_BR "BR" +#define HTTP_LEN_BR 2 + // from mod_deflate: // ZLIB's compression algorithm uses a // 0-9 based scale that GZIP does where '1' is 'Best speed' @@ -618,15 +622,15 @@ stats_origin(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata) if (accept_encoding_field != TS_NULL_MLOC) { int len = -1; const char *str = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, accept_encoding_field, -1, &len); - if (strstr(str, "deflate") != NULL) { + if (len >= TS_HTTP_LEN_DEFLATE && strstr(str, TS_HTTP_VALUE_DEFLATE) != NULL) { TSDebug(PLUGIN_NAME, "Saw deflate in accept encoding"); my_state->encoding = init_gzip(my_state, DEFLATE_MODE); - } else if (strstr(str, "gzip") != NULL) { + } else if (len >= TS_HTTP_LEN_GZIP && strstr(str, TS_HTTP_VALUE_GZIP) != NULL) { TSDebug(PLUGIN_NAME, "Saw gzip in accept encoding"); my_state->encoding = init_gzip(my_state, GZIP_MODE); } #if HAVE_BROTLI_ENCODE_H - else if (strstr(str, "br") != NULL) { + else if (len >= HTTP_LEN_BR && strstr(str, HTTP_VALUE_BR) != NULL) { TSDebug(PLUGIN_NAME, "Saw br in accept encoding"); my_state->encoding = init_br(my_state); }