On Tue, Dec 29, 2015 at 3:24 PM, Jim Jagielski <j...@jagunet.com> wrote: > ping. > > Just a reminder that right now, trunk uses ap_casecmpstr[n](), > which can make some backport requests "problematic" due to > possible merge conflicts.
I've just committed (in r1722150) more reverts of abusive ap_casecmpstr[n]() usage I introduced in r1715880. This now leave us the attached 2.4.x backport patch should we decide to apply these changes to 2.4.x. > > Can we *please* decide what we are doing? I'd vote for the backport...
Index: include/ap_mmn.h =================================================================== --- include/ap_mmn.h (revision 1722143) +++ include/ap_mmn.h (working copy) @@ -457,6 +457,7 @@ * ap_get_protocol(). Add HTTP_MISDIRECTED_REQUEST. * Added ap_parse_token_list_strict() to httpd.h * 20120211.52 (2.4.17-dev) Add master conn_rec* member in conn_rec. + * 20120211.53 (2.4.19-dev) Add ap_casecmpstr[n](); */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -464,7 +465,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20120211 #endif -#define MODULE_MAGIC_NUMBER_MINOR 52 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 53 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a Index: include/httpd.h =================================================================== --- include/httpd.h (revision 1722143) +++ include/httpd.h (working copy) @@ -2312,6 +2312,27 @@ AP_DECLARE(int) ap_array_str_index(const apr_array AP_DECLARE(int) ap_array_str_contains(const apr_array_header_t *array, const char *s); +/** + * Known-fast version of strcasecmp(): ASCII case-folding, POSIX compliant + * @param s1 The 1st string to compare + * @param s2 The 2nd string to compare + * @return integer greater than, equal to, or less than 0, depending on + * if s1 is lexicographically greater than, equal to, or less + * than s2 ignoring case. + */ +AP_DECLARE(int) ap_casecmpstr(const char *s1, const char *s2); + +/** + * Known-fast version of strncasecmp(): ASCII case-folding, POSIX compliant + * @param s1 The 1st string to compare + * @param s2 The 2nd string to compare + * @param n Maximum number of characters in the strings to compare + * @return integer greater than, equal to, or less than 0, depending on + * if s1 is lexicographically greater than, equal to, or less + * than s2 ignoring case. + */ +AP_DECLARE(int) ap_casecmpstrn(const char *s1, const char *s2, apr_size_t n); + #ifdef __cplusplus } #endif Index: modules/aaa/mod_auth_basic.c =================================================================== --- modules/aaa/mod_auth_basic.c (revision 1722143) +++ modules/aaa/mod_auth_basic.c (working copy) @@ -242,7 +242,7 @@ static void note_basic_auth_failure(request_rec *r static int hook_note_basic_auth_failure(request_rec *r, const char *auth_type) { - if (strcasecmp(auth_type, "Basic")) + if (ap_casecmpstr(auth_type, "Basic")) return DECLINED; note_basic_auth_failure(r); @@ -265,7 +265,7 @@ static int get_basic_auth(request_rec *r, const ch return HTTP_UNAUTHORIZED; } - if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) { + if (ap_casecmpstr(ap_getword(r->pool, &auth_line, ' '), "Basic")) { /* Client tried to authenticate using wrong auth scheme */ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01614) "client used wrong authentication scheme: %s", r->uri); @@ -305,7 +305,7 @@ static int authenticate_basic_user(request_rec *r) /* Are we configured to be Basic auth? */ current_auth = ap_auth_type(r); - if (!current_auth || strcasecmp(current_auth, "Basic")) { + if (!current_auth || ap_casecmpstr(current_auth, "Basic")) { return DECLINED; } Index: modules/aaa/mod_auth_digest.c =================================================================== --- modules/aaa/mod_auth_digest.c (revision 1722143) +++ modules/aaa/mod_auth_digest.c (working copy) @@ -541,7 +541,7 @@ static const char *set_qop(cmd_parms *cmd, void *c if (!strcasecmp(op, "auth-int")) { return "AuthDigestQop auth-int is not implemented"; } - else if (strcasecmp(op, "auth")) { + else if (ap_casecmpstr(op, "auth")) { return apr_pstrcat(cmd->pool, "Unrecognized qop: ", op, NULL); } @@ -594,7 +594,7 @@ static const char *set_algorithm(cmd_parms *cmd, v return "AuthDigestAlgorithm: ERROR: algorithm `MD5-sess' " "is not fully implemented"; } - else if (strcasecmp(alg, "MD5")) { + else if (ap_casecmpstr(alg, "MD5")) { return apr_pstrcat(cmd->pool, "Invalid algorithm in AuthDigestAlgorithm: ", alg, NULL); } @@ -893,7 +893,7 @@ static int get_digest_rec(request_rec *r, digest_h } resp->scheme = ap_getword_white(r->pool, &auth_line); - if (strcasecmp(resp->scheme, "Digest")) { + if (ap_casecmpstr(resp->scheme, "Digest")) { resp->auth_hdr_sts = NOT_DIGEST; return !OK; } @@ -957,25 +957,25 @@ static int get_digest_rec(request_rec *r, digest_h auth_line++; } - if (!strcasecmp(key, "username")) + if (!ap_casecmpstr(key, "username")) resp->username = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "realm")) + else if (!ap_casecmpstr(key, "realm")) resp->realm = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "nonce")) + else if (!ap_casecmpstr(key, "nonce")) resp->nonce = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "uri")) + else if (!ap_casecmpstr(key, "uri")) resp->uri = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "response")) + else if (!ap_casecmpstr(key, "response")) resp->digest = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "algorithm")) + else if (!ap_casecmpstr(key, "algorithm")) resp->algorithm = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "cnonce")) + else if (!ap_casecmpstr(key, "cnonce")) resp->cnonce = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "opaque")) + else if (!ap_casecmpstr(key, "opaque")) resp->opaque = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "qop")) + else if (!ap_casecmpstr(key, "qop")) resp->message_qop = apr_pstrdup(r->pool, value); - else if (!strcasecmp(key, "nc")) + else if (!ap_casecmpstr(key, "nc")) resp->nonce_count = apr_pstrdup(r->pool, value); } @@ -1234,7 +1234,7 @@ static void note_digest_auth_failure(request_rec * if (apr_is_empty_array(conf->qop_list)) { qop = ", qop=\"auth\""; } - else if (!strcasecmp(*(const char **)(conf->qop_list->elts), "none")) { + else if (!ap_casecmpstr(*(const char **)(conf->qop_list->elts), "none")) { qop = ""; } else { @@ -1333,7 +1333,7 @@ static int hook_note_digest_auth_failure(request_r digest_header_rec *resp; digest_config_rec *conf; - if (strcasecmp(auth_type, "Digest")) + if (ap_casecmpstr(auth_type, "Digest")) return DECLINED; /* get the client response and mark */ @@ -1443,7 +1443,7 @@ static int check_nc(const request_rec *r, const di } if (!apr_is_empty_array(conf->qop_list) && - !strcasecmp(*(const char **)(conf->qop_list->elts), "none")) { + !ap_casecmpstr(*(const char **)(conf->qop_list->elts), "none")) { /* qop is none, client must not send a nonce count */ if (snc != NULL) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01772) @@ -1660,7 +1660,7 @@ static int authenticate_digest_user(request_rec *r /* do we require Digest auth for this URI? */ - if (!(t = ap_auth_type(r)) || strcasecmp(t, "Digest")) { + if (!(t = ap_auth_type(r)) || ap_casecmpstr(t, "Digest")) { return DECLINED; } @@ -1828,8 +1828,8 @@ static int authenticate_digest_user(request_rec *r } if (resp->algorithm != NULL - && strcasecmp(resp->algorithm, "MD5") - && strcasecmp(resp->algorithm, "MD5-sess")) { + && ap_casecmpstr(resp->algorithm, "MD5") + && ap_casecmpstr(resp->algorithm, "MD5-sess")) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01789) "unknown algorithm `%s' received: %s", resp->algorithm, r->uri); @@ -1880,7 +1880,7 @@ static int authenticate_digest_user(request_rec *r int match = 0, idx; const char **tmp = (const char **)(conf->qop_list->elts); for (idx = 0; idx < conf->qop_list->nelts; idx++) { - if (!strcasecmp(*tmp, resp->message_qop)) { + if (!ap_casecmpstr(*tmp, resp->message_qop)) { match = 1; break; } @@ -1889,7 +1889,7 @@ static int authenticate_digest_user(request_rec *r if (!match && !(apr_is_empty_array(conf->qop_list) - && !strcasecmp(resp->message_qop, "auth"))) { + && !ap_casecmpstr(resp->message_qop, "auth"))) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01793) "invalid qop `%s' received: %s", resp->message_qop, r->uri); @@ -1971,7 +1971,7 @@ static int add_auth_info(request_rec *r) /* do rfc-2069 digest */ if (!apr_is_empty_array(conf->qop_list) && - !strcasecmp(*(const char **)(conf->qop_list->elts), "none") + !ap_casecmpstr(*(const char **)(conf->qop_list->elts), "none") && resp->message_qop == NULL) { /* use only RFC-2069 format */ ai = nextnonce; Index: modules/aaa/mod_auth_form.c =================================================================== --- modules/aaa/mod_auth_form.c (revision 1722143) +++ modules/aaa/mod_auth_form.c (working copy) @@ -420,7 +420,7 @@ static void note_cookie_auth_failure(request_rec * static int hook_note_cookie_auth_failure(request_rec * r, const char *auth_type) { - if (strcasecmp(auth_type, "form")) + if (ap_casecmpstr(auth_type, "form")) return DECLINED; note_cookie_auth_failure(r); @@ -892,7 +892,7 @@ static int authenticate_form_authn(request_rec * r /* Are we configured to be Form auth? */ current_auth = ap_auth_type(r); - if (!current_auth || strcasecmp(current_auth, "form")) { + if (!current_auth || ap_casecmpstr(current_auth, "form")) { return DECLINED; } Index: modules/aaa/mod_authnz_fcgi.c =================================================================== --- modules/aaa/mod_authnz_fcgi.c (revision 1722143) +++ modules/aaa/mod_authnz_fcgi.c (working copy) @@ -681,7 +681,7 @@ static int mod_fcgid_modify_auth_header(void *vars /* When the application gives a 200 response, the server ignores response headers whose names aren't prefixed with Variable- prefix, and ignores any response content */ - if (strncasecmp(key, "Variable-", 9) == 0) + if (ap_casecmpstrn(key, "Variable-", 9) == 0) apr_table_setn(vars, key, val); return 1; } @@ -809,7 +809,7 @@ static int fcgi_check_authn(request_rec *r) prov = dconf && dconf->name ? dconf->name : NULL; - if (!prov || !strcasecmp(prov, "None")) { + if (!prov || !ap_casecmpstr(prov, "None")) { return DECLINED; } @@ -824,7 +824,7 @@ static int fcgi_check_authn(request_rec *r) dconf->user_expr ? "yes" : "no", auth_type); - if (auth_type && !strcasecmp(auth_type, "Basic")) { + if (auth_type && !ap_casecmpstr(auth_type, "Basic")) { if ((res = ap_get_basic_auth_pw(r, &password))) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02517) "%s: couldn't retrieve basic auth " Index: modules/cache/cache_storage.c =================================================================== --- modules/cache/cache_storage.c (revision 1722143) +++ modules/cache/cache_storage.c (working copy) @@ -115,7 +115,7 @@ int cache_create_entity(cache_request_rec *cache, static int filter_header_do(void *v, const char *key, const char *val) { - if ((*key == 'W' || *key == 'w') && !strcasecmp(key, "Warning") + if ((*key == 'W' || *key == 'w') && !ap_casecmpstr(key, "Warning") && *val == '1') { /* any stored Warning headers with warn-code 1xx (see section * 14.46) MUST be deleted from the cache entry and the forwarded @@ -129,7 +129,7 @@ static int filter_header_do(void *v, const char *k } static int remove_header_do(void *v, const char *key, const char *val) { - if ((*key == 'W' || *key == 'w') && !strcasecmp(key, "Warning")) { + if ((*key == 'W' || *key == 'w') && !ap_casecmpstr(key, "Warning")) { /* any stored Warning headers with warn-code 2xx MUST be retained * in the cache entry and the forwarded response. */ Index: modules/cache/cache_util.c =================================================================== --- modules/cache/cache_util.c (revision 1722143) +++ modules/cache/cache_util.c (working copy) @@ -55,7 +55,7 @@ static int uri_meets_conditions(const apr_uri_t *f } else { /* The URI scheme must be present and identical except for case. */ - if (!url->scheme || strcasecmp(filter->scheme, url->scheme)) { + if (!url->scheme || ap_casecmpstr(filter->scheme, url->scheme)) { return 0; } @@ -976,14 +976,9 @@ int ap_cache_control(request_rec *r, cache_control char *header = apr_pstrdup(r->pool, pragma_header); const char *token = cache_strqtok(header, CACHE_SEPARATOR, &last); while (token) { - /* handle most common quickest case... */ - if (!strcmp(token, "no-cache")) { + if (!ap_casecmpstr(token, "no-cache")) { cc->no_cache = 1; } - /* ...then try slowest case */ - else if (!strcasecmp(token, "no-cache")) { - cc->no_cache = 1; - } token = cache_strqtok(NULL, CACHE_SEPARATOR, &last); } cc->pragma = 1; @@ -996,15 +991,7 @@ int ap_cache_control(request_rec *r, cache_control switch (token[0]) { case 'n': case 'N': { - /* handle most common quickest cases... */ - if (!strcmp(token, "no-cache")) { - cc->no_cache = 1; - } - else if (!strcmp(token, "no-store")) { - cc->no_store = 1; - } - /* ...then try slowest cases */ - else if (!strncasecmp(token, "no-cache", 8)) { + if (!ap_casecmpstrn(token, "no-cache", 8)) { if (token[8] == '=') { cc->no_cache_header = 1; } @@ -1011,12 +998,11 @@ int ap_cache_control(request_rec *r, cache_control else if (!token[8]) { cc->no_cache = 1; } - break; } - else if (!strcasecmp(token, "no-store")) { + else if (!ap_casecmpstr(token, "no-store")) { cc->no_store = 1; } - else if (!strcasecmp(token, "no-transform")) { + else if (!ap_casecmpstr(token, "no-transform")) { cc->no_transform = 1; } break; @@ -1023,23 +1009,16 @@ int ap_cache_control(request_rec *r, cache_control } case 'm': case 'M': { - /* handle most common quickest cases... */ - if (!strcmp(token, "max-age=0")) { - cc->max_age = 1; - cc->max_age_value = 0; - } - else if (!strcmp(token, "must-revalidate")) { - cc->must_revalidate = 1; - } - /* ...then try slowest cases */ - else if (!strncasecmp(token, "max-age", 7)) { + if (!ap_casecmpstrn(token, "max-age", 7)) { if (token[7] == '=') { cc->max_age = 1; cc->max_age_value = apr_atoi64(token + 8); } - break; } - else if (!strncasecmp(token, "max-stale", 9)) { + else if (!ap_casecmpstr(token, "must-revalidate")) { + cc->must_revalidate = 1; + } + else if (!ap_casecmpstrn(token, "max-stale", 9)) { if (token[9] == '=') { cc->max_stale = 1; cc->max_stale_value = apr_atoi64(token + 10); @@ -1048,23 +1027,18 @@ int ap_cache_control(request_rec *r, cache_control cc->max_stale = 1; cc->max_stale_value = -1; } - break; } - else if (!strncasecmp(token, "min-fresh", 9)) { + else if (!ap_casecmpstrn(token, "min-fresh", 9)) { if (token[9] == '=') { cc->min_fresh = 1; cc->min_fresh_value = apr_atoi64(token + 10); } - break; } - else if (!strcasecmp(token, "must-revalidate")) { - cc->must_revalidate = 1; - } break; } case 'o': case 'O': { - if (!strcasecmp(token, "only-if-cached")) { + if (!ap_casecmpstr(token, "only-if-cached")) { cc->only_if_cached = 1; } break; @@ -1071,15 +1045,10 @@ int ap_cache_control(request_rec *r, cache_control } case 'p': case 'P': { - /* handle most common quickest cases... */ - if (!strcmp(token, "private")) { - cc->private = 1; - } - /* ...then try slowest cases */ - else if (!strcasecmp(token, "public")) { + if (!ap_casecmpstr(token, "public")) { cc->public = 1; } - else if (!strncasecmp(token, "private", 7)) { + else if (!ap_casecmpstrn(token, "private", 7)) { if (token[7] == '=') { cc->private_header = 1; } @@ -1086,9 +1055,8 @@ int ap_cache_control(request_rec *r, cache_control else if (!token[7]) { cc->private = 1; } - break; } - else if (!strcasecmp(token, "proxy-revalidate")) { + else if (!ap_casecmpstr(token, "proxy-revalidate")) { cc->proxy_revalidate = 1; } break; @@ -1095,12 +1063,11 @@ int ap_cache_control(request_rec *r, cache_control } case 's': case 'S': { - if (!strncasecmp(token, "s-maxage", 8)) { + if (!ap_casecmpstrn(token, "s-maxage", 8)) { if (token[8] == '=') { cc->s_maxage = 1; cc->s_maxage_value = apr_atoi64(token + 9); } - break; } break; } @@ -1130,8 +1097,7 @@ static int cache_control_remove(request_rec *r, co switch (token[0]) { case 'n': case 'N': { - if (!strncmp(token, "no-cache", 8) - || !strncasecmp(token, "no-cache", 8)) { + if (!ap_casecmpstrn(token, "no-cache", 8)) { if (token[8] == '=') { const char *header = cache_strqtok(token + 9, CACHE_SEPARATOR "\"", &slast); @@ -1148,8 +1114,7 @@ static int cache_control_remove(request_rec *r, co } case 'p': case 'P': { - if (!strncmp(token, "private", 7) - || !strncasecmp(token, "private", 7)) { + if (!ap_casecmpstrn(token, "private", 7)) { if (token[7] == '=') { const char *header = cache_strqtok(token + 8, CACHE_SEPARATOR "\"", &slast); Index: modules/dav/main/mod_dav.c =================================================================== --- modules/dav/main/mod_dav.c (revision 1722143) +++ modules/dav/main/mod_dav.c (working copy) @@ -651,7 +651,7 @@ DAV_DECLARE(int) dav_get_depth(request_rec *r, int return def_depth; } - if (strcasecmp(depth, "infinity") == 0) { + if (ap_casecmpstr(depth, "infinity") == 0) { return DAV_INFINITY; } else if (strcmp(depth, "0") == 0) { @@ -781,7 +781,7 @@ static int dav_parse_range(request_rec *r, return 0; range = apr_pstrdup(r->pool, range_c); - if (strncasecmp(range, "bytes ", 6) != 0 + if (ap_casecmpstrn(range, "bytes ", 6) != 0 || (dash = ap_strchr(range, '-')) == NULL || (slash = ap_strchr(range, '/')) == NULL) { /* malformed header */ @@ -2451,7 +2451,7 @@ static int process_mkcol_body(request_rec *r) r->remaining = 0; if (tenc) { - if (strcasecmp(tenc, "chunked")) { + if (ap_casecmpstr(tenc, "chunked")) { /* Use this instead of Apache's default error string */ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00589) "Unknown Transfer-Encoding %s", tenc); Index: modules/dav/main/util.c =================================================================== --- modules/dav/main/util.c (revision 1722143) +++ modules/dav/main/util.c (working copy) @@ -240,7 +240,7 @@ DAV_DECLARE(dav_lookup_result) dav_lookup_uri(cons request. the port must match our port. */ port = r->connection->local_addr->port; - if (strcasecmp(comp.scheme, scheme) != 0 + if (ap_casecmpstr(comp.scheme, scheme) != 0 #ifdef APACHE_PORT_HANDLING_IS_BUSTED || comp.port != port #endif Index: modules/filters/mod_charset_lite.c =================================================================== --- modules/filters/mod_charset_lite.c (revision 1722143) +++ modules/filters/mod_charset_lite.c (working copy) @@ -790,7 +790,7 @@ static apr_status_t xlate_out_filter(ap_filter_t * if (!ctx->noop && ctx->xlate == NULL) { const char *mime_type = f->r->content_type; - if (mime_type && (strncasecmp(mime_type, "text/", 5) == 0 || + if (mime_type && (ap_casecmpstrn(mime_type, "text/", 5) == 0 || #if APR_CHARSET_EBCDIC /* On an EBCDIC machine, be willing to translate mod_autoindex- * generated output. Otherwise, it doesn't look too cool. @@ -806,7 +806,7 @@ static apr_status_t xlate_out_filter(ap_filter_t * */ strcmp(mime_type, DIR_MAGIC_TYPE) == 0 || #endif - strncasecmp(mime_type, "message/", 8) == 0 || + ap_casecmpstrn(mime_type, "message/", 8) == 0 || dc->force_xlate == FX_FORCE)) { rv = apr_xlate_open(&ctx->xlate, Index: modules/filters/mod_deflate.c =================================================================== --- modules/filters/mod_deflate.c (revision 1722143) +++ modules/filters/mod_deflate.c (working copy) @@ -118,8 +118,8 @@ static int check_gzip(request_rec *r, apr_table_t if (encoding && *encoding) { /* check the usual/simple case first */ - if (!strcasecmp(encoding, "gzip") - || !strcasecmp(encoding, "x-gzip")) { + if (!ap_casecmpstr(encoding, "gzip") + || !ap_casecmpstr(encoding, "x-gzip")) { found = 1; if (hdrs) { apr_table_unset(hdrs, "Content-Encoding"); @@ -137,8 +137,8 @@ static int check_gzip(request_rec *r, apr_table_t for(;;) { char *token = ap_strrchr(new_encoding, ','); if (!token) { /* gzip:identity or other:identity */ - if (!strcasecmp(new_encoding, "gzip") - || !strcasecmp(new_encoding, "x-gzip")) { + if (!ap_casecmpstr(new_encoding, "gzip") + || !ap_casecmpstr(new_encoding, "x-gzip")) { found = 1; if (hdrs) { apr_table_unset(hdrs, "Content-Encoding"); @@ -150,8 +150,8 @@ static int check_gzip(request_rec *r, apr_table_t break; /* seen all tokens */ } for (ptr=token+1; apr_isspace(*ptr); ++ptr); - if (!strcasecmp(ptr, "gzip") - || !strcasecmp(ptr, "x-gzip")) { + if (!ap_casecmpstr(ptr, "gzip") + || !ap_casecmpstr(ptr, "x-gzip")) { *token = '\0'; if (hdrs) { apr_table_setn(hdrs, "Content-Encoding", new_encoding); @@ -161,7 +161,7 @@ static int check_gzip(request_rec *r, apr_table_t } found = 1; } - else if (!ptr[0] || !strcasecmp(ptr, "identity")) { + else if (!ptr[0] || !ap_casecmpstr(ptr, "identity")) { *token = '\0'; continue; /* strip the token and find the next one */ } @@ -704,7 +704,7 @@ static apr_status_t deflate_out_filter(ap_filter_t } token = ap_get_token(r->pool, &accepts, 0); - while (token && token[0] && strcasecmp(token, "gzip")) { + while (token && token[0] && ap_casecmpstr(token, "gzip")) { /* skip parameters, XXX: ;q=foo evaluation? */ while (*accepts == ';') { ++accepts; @@ -778,7 +778,7 @@ static apr_status_t deflate_out_filter(ap_filter_t */ /* If the entire Content-Encoding is "identity", we can replace it. */ - if (!encoding || !strcasecmp(encoding, "identity")) { + if (!encoding || !ap_casecmpstr(encoding, "identity")) { apr_table_setn(r->headers_out, "Content-Encoding", "gzip"); } else { Index: modules/filters/mod_include.c =================================================================== --- modules/filters/mod_include.c (revision 1722143) +++ modules/filters/mod_include.c (working copy) @@ -1950,25 +1950,25 @@ static apr_status_t handle_echo(include_ctx_t *ctx token = apr_strtok(d, ", \t", &last); while (token) { - if (!strcasecmp(token, "none")) { + if (!ap_casecmpstr(token, "none")) { /* do nothing */ } - else if (!strcasecmp(token, "url")) { + else if (!ap_casecmpstr(token, "url")) { char *buf = apr_pstrdup(ctx->pool, echo_text); ap_unescape_url(buf); echo_text = buf; } - else if (!strcasecmp(token, "urlencoded")) { + else if (!ap_casecmpstr(token, "urlencoded")) { char *buf = apr_pstrdup(ctx->pool, echo_text); ap_unescape_urlencoded(buf); echo_text = buf; } - else if (!strcasecmp(token, "entity")) { + else if (!ap_casecmpstr(token, "entity")) { char *buf = apr_pstrdup(ctx->pool, echo_text); decodehtml(buf); echo_text = buf; } - else if (!strcasecmp(token, "base64")) { + else if (!ap_casecmpstr(token, "base64")) { echo_text = ap_pbase64decode(ctx->dpool, echo_text); } else { @@ -1986,19 +1986,19 @@ static apr_status_t handle_echo(include_ctx_t *ctx token = apr_strtok(e, ", \t", &last); while (token) { - if (!strcasecmp(token, "none")) { + if (!ap_casecmpstr(token, "none")) { /* do nothing */ } - else if (!strcasecmp(token, "url")) { + else if (!ap_casecmpstr(token, "url")) { echo_text = ap_escape_uri(ctx->dpool, echo_text); } - else if (!strcasecmp(token, "urlencoded")) { + else if (!ap_casecmpstr(token, "urlencoded")) { echo_text = ap_escape_urlencoded(ctx->dpool, echo_text); } - else if (!strcasecmp(token, "entity")) { + else if (!ap_casecmpstr(token, "entity")) { echo_text = ap_escape_html2(ctx->dpool, echo_text, 0); } - else if (!strcasecmp(token, "base64")) { + else if (!ap_casecmpstr(token, "base64")) { char *buf; buf = ap_pbase64encode(ctx->dpool, (char *)echo_text); echo_text = buf; @@ -2588,25 +2588,25 @@ static apr_status_t handle_set(include_ctx_t *ctx, token = apr_strtok(d, ", \t", &last); while (token) { - if (!strcasecmp(token, "none")) { + if (!ap_casecmpstr(token, "none")) { /* do nothing */ } - else if (!strcasecmp(token, "url")) { + else if (!ap_casecmpstr(token, "url")) { char *buf = apr_pstrdup(ctx->pool, parsed_string); ap_unescape_url(buf); parsed_string = buf; } - else if (!strcasecmp(token, "urlencoded")) { + else if (!ap_casecmpstr(token, "urlencoded")) { char *buf = apr_pstrdup(ctx->pool, parsed_string); ap_unescape_urlencoded(buf); parsed_string = buf; } - else if (!strcasecmp(token, "entity")) { + else if (!ap_casecmpstr(token, "entity")) { char *buf = apr_pstrdup(ctx->pool, parsed_string); decodehtml(buf); parsed_string = buf; } - else if (!strcasecmp(token, "base64")) { + else if (!ap_casecmpstr(token, "base64")) { parsed_string = ap_pbase64decode(ctx->dpool, parsed_string); } else { @@ -2624,19 +2624,19 @@ static apr_status_t handle_set(include_ctx_t *ctx, token = apr_strtok(e, ", \t", &last); while (token) { - if (!strcasecmp(token, "none")) { + if (!ap_casecmpstr(token, "none")) { /* do nothing */ } - else if (!strcasecmp(token, "url")) { + else if (!ap_casecmpstr(token, "url")) { parsed_string = ap_escape_uri(ctx->dpool, parsed_string); } - else if (!strcasecmp(token, "urlencoded")) { + else if (!ap_casecmpstr(token, "urlencoded")) { parsed_string = ap_escape_urlencoded(ctx->dpool, parsed_string); } - else if (!strcasecmp(token, "entity")) { + else if (!ap_casecmpstr(token, "entity")) { parsed_string = ap_escape_html2(ctx->dpool, parsed_string, 0); } - else if (!strcasecmp(token, "base64")) { + else if (!ap_casecmpstr(token, "base64")) { char *buf; buf = ap_pbase64encode(ctx->dpool, (char *)parsed_string); parsed_string = buf; Index: modules/filters/mod_proxy_html.c =================================================================== --- modules/filters/mod_proxy_html.c (revision 1722143) +++ modules/filters/mod_proxy_html.c (working copy) @@ -660,7 +660,7 @@ static meta *metafix(request_rec *r, const char *b while (!apr_isalpha(*++p)); for (q = p; apr_isalnum(*q) || (*q == '-'); ++q); header = apr_pstrndup(r->pool, p, q-p); - if (strncasecmp(header, "Content-", 8)) { + if (ap_casecmpstrn(header, "Content-", 8)) { /* find content=... string */ p = apr_strmatch(seek_content, buf+offs+pmatch[0].rm_so, pmatch[0].rm_eo - pmatch[0].rm_so); @@ -688,7 +688,7 @@ static meta *metafix(request_rec *r, const char *b } } } - else if (!strncasecmp(header, "Content-Type", 12)) { + else if (!ap_casecmpstrn(header, "Content-Type", 12)) { ret = apr_palloc(r->pool, sizeof(meta)); ret->start = offs+pmatch[0].rm_so; ret->end = offs+pmatch[0].rm_eo; @@ -812,8 +812,8 @@ static saxctxt *check_filter_init (ap_filter_t *f) else if (!f->r->content_type) { errmsg = "No content-type; bailing out of proxy-html filter"; } - else if (strncasecmp(f->r->content_type, "text/html", 9) && - strncasecmp(f->r->content_type, + else if (ap_casecmpstrn(f->r->content_type, "text/html", 9) && + ap_casecmpstrn(f->r->content_type, "application/xhtml+xml", 21)) { errmsg = "Non-HTML content; not inserting proxy-html filter"; } Index: modules/generators/mod_autoindex.c =================================================================== --- modules/generators/mod_autoindex.c (revision 1722143) +++ modules/generators/mod_autoindex.c (working copy) @@ -1068,7 +1068,7 @@ static void emit_head(request_rec *r, char *header emit_H1 = 1; } } - else if (!strncasecmp("text/", rr->content_type, 5)) { + else if (!ap_casecmpstrn("text/", rr->content_type, 5)) { /* * If we can open the file, prefix it with the preamble * regardless; since we'll be sending a <pre> block around @@ -1163,7 +1163,7 @@ static void emit_tail(request_rec *r, char *readme suppress_post = suppress_amble; } } - else if (!strncasecmp("text/", rr->content_type, 5)) { + else if (!ap_casecmpstrn("text/", rr->content_type, 5)) { /* * If we can open the file, suppress the signature. */ Index: modules/generators/mod_info.c =================================================================== --- modules/generators/mod_info.c (revision 1722143) +++ modules/generators/mod_info.c (working copy) @@ -785,7 +785,7 @@ static int display_info(request_rec * r) " <title>Server Information</title>\n" "</head>\n", r); ap_rputs("<body><h1 style=\"text-align: center\">" "Apache Server Information</h1>\n", r); - if (!r->args || strcasecmp(r->args, "list")) { + if (!r->args || ap_casecmpstr(r->args, "list")) { if (!r->args) { ap_rputs("<dl><dt><tt>Subpages:<br />", r); ap_rputs("<a href=\"?config\">Configuration Files</a>, " @@ -819,19 +819,19 @@ static int display_info(request_rec * r) ap_rputs("</tt></dt></dl><hr />", r); } - if (!r->args || !strcasecmp(r->args, "server")) { + if (!r->args || !ap_casecmpstr(r->args, "server")) { show_server_settings(r); } - if (!r->args || !strcasecmp(r->args, "hooks")) { + if (!r->args || !ap_casecmpstr(r->args, "hooks")) { show_active_hooks(r); } - if (!r->args || !strcasecmp(r->args, "providers")) { + if (!r->args || !ap_casecmpstr(r->args, "providers")) { show_providers(r); } - if (r->args && 0 == strcasecmp(r->args, "config")) { + if (r->args && 0 == ap_casecmpstr(r->args, "config")) { ap_rputs("<dl><dt><strong>Configuration:</strong>\n", r); mod_info_module_cmds(r, NULL, ap_conftree, 0, 0); ap_rputs("</dl><hr />", r); @@ -842,7 +842,7 @@ static int display_info(request_rec * r) modules = get_sorted_modules(r->pool); for (i = 0; i < modules->nelts; i++) { modp = APR_ARRAY_IDX(modules, i, module *); - if (!r->args || !strcasecmp(modp->name, r->args)) { + if (!r->args || !ap_casecmpstr(modp->name, r->args)) { ap_rprintf(r, "<dl><dt><a name=\"%s\"><strong>Module Name:</strong></a> " "<font size=\"+1\"><tt><a href=\"?%s\">%s</a></tt></font></dt>\n", @@ -940,7 +940,7 @@ static int display_info(request_rec * r) } } } - if (!modp && r->args && strcasecmp(r->args, "server")) { + if (!modp && r->args && ap_casecmpstr(r->args, "server")) { ap_rputs("<p><b>No such module</b></p>\n", r); } } Index: modules/http/byterange_filter.c =================================================================== --- modules/http/byterange_filter.c (revision 1722143) +++ modules/http/byterange_filter.c (working copy) @@ -115,7 +115,7 @@ static int ap_set_byterange(request_rec *r, apr_of range = apr_table_get(r->headers_in, "Request-Range"); } - if (!range || strncasecmp(range, "bytes=", 6) || r->status != HTTP_OK) { + if (!range || ap_casecmpstrn(range, "bytes=", 6) || r->status != HTTP_OK) { return 0; } @@ -126,8 +126,8 @@ static int ap_set_byterange(request_rec *r, apr_of /* is content already a multiple range? */ if ((ct = apr_table_get(r->headers_out, "Content-Type")) - && (!strncasecmp(ct, "multipart/byteranges", 20) - || !strncasecmp(ct, "multipart/x-byteranges", 22))) { + && (!ap_casecmpstrn(ct, "multipart/byteranges", 20) + || !ap_casecmpstrn(ct, "multipart/x-byteranges", 22))) { return 0; } Index: modules/http/http_filters.c =================================================================== --- modules/http/http_filters.c (revision 1722143) +++ modules/http/http_filters.c (working copy) @@ -363,7 +363,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bu lenp = apr_table_get(f->r->headers_in, "Content-Length"); if (tenc) { - if (strcasecmp(tenc, "chunked") == 0 /* fast path */ + if (ap_casecmpstr(tenc, "chunked") == 0 /* fast path */ || ap_find_last_token(f->r->pool, tenc, "chunked")) { ctx->state = BODY_CHUNK; } @@ -749,7 +749,7 @@ static int uniq_field_values(void *d, const char * */ for (i = 0, strpp = (char **) values->elts; i < values->nelts; ++i, ++strpp) { - if (*strpp && strcasecmp(*strpp, start) == 0) { + if (*strpp && ap_casecmpstr(*strpp, start) == 0) { break; } } @@ -1282,7 +1282,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_heade while (field && (token = ap_get_list_item(r->pool, &field)) != NULL) { for (i = 0; i < r->content_languages->nelts; ++i) { - if (!strcasecmp(token, languages[i])) + if (!ap_casecmpstr(token, languages[i])) break; } if (i == r->content_languages->nelts) { @@ -1534,7 +1534,7 @@ AP_DECLARE(int) ap_setup_client_block(request_rec r->remaining = 0; if (tenc) { - if (strcasecmp(tenc, "chunked")) { + if (ap_casecmpstr(tenc, "chunked")) { ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(01592) "Unknown Transfer-Encoding %s", tenc); return HTTP_NOT_IMPLEMENTED; Index: modules/http2/h2_from_h1.c =================================================================== --- modules/http2/h2_from_h1.c (revision 1722143) +++ modules/http2/h2_from_h1.c (working copy) @@ -258,7 +258,7 @@ static int uniq_field_values(void *d, const char * */ for (i = 0, strpp = (char **) values->elts; i < values->nelts; ++i, ++strpp) { - if (*strpp && strcasecmp(*strpp, start) == 0) { + if (*strpp && ap_casecmpstr(*strpp, start) == 0) { break; } } @@ -408,7 +408,7 @@ static h2_response *create_response(h2_from_h1 *fr while (field && (token = ap_get_list_item(r->pool, &field)) != NULL) { for (i = 0; i < r->content_languages->nelts; ++i) { - if (!strcasecmp(token, languages[i])) + if (!ap_casecmpstr(token, languages[i])) break; } if (i == r->content_languages->nelts) { Index: modules/loggers/mod_log_config.c =================================================================== --- modules/loggers/mod_log_config.c (revision 1722143) +++ modules/loggers/mod_log_config.c (working copy) @@ -466,7 +466,7 @@ static APR_INLINE char *find_multiple_headers(apr_ result_list = rp = NULL; do { - if (!strcasecmp(t_elt->key, key)) { + if (!ap_casecmpstr(t_elt->key, key)) { if (!result_list) { result_list = rp = apr_palloc(pool, sizeof(*rp)); } @@ -510,10 +510,10 @@ static const char *log_header_out(request_rec *r, { const char *cp = NULL; - if (!strcasecmp(a, "Content-type") && r->content_type) { + if (!ap_casecmpstr(a, "Content-type") && r->content_type) { cp = ap_field_noparam(r->pool, r->content_type); } - else if (!strcasecmp(a, "Set-Cookie")) { + else if (!ap_casecmpstr(a, "Set-Cookie")) { cp = find_multiple_headers(r->pool, r->headers_out, a); } else { @@ -569,7 +569,7 @@ static const char *log_cookie(request_rec *r, char --last; } - if (!strcasecmp(name, a)) { + if (!ap_casecmpstr(name, a)) { /* last1 points to the next char following the ';' delim, or the trailing NUL char of the string */ last = last1 - (*last1 ? 2 : 1); Index: modules/mappers/mod_negotiation.c =================================================================== --- modules/mappers/mod_negotiation.c (revision 1722143) +++ modules/mappers/mod_negotiation.c (working copy) @@ -774,7 +774,7 @@ static enum header_state get_header_line(char *buf /* We need to shortcut the rest of this block following the Body: * tag - we will not look for continutation after this line. */ - if (!strncasecmp(buffer, "Body:", 5)) + if (!ap_casecmpstrn(buffer, "Body:", 5)) return header_seen; while (apr_file_getc(&c, map) != APR_EOF) { Index: modules/mappers/mod_rewrite.c =================================================================== --- modules/mappers/mod_rewrite.c (revision 1722143) +++ modules/mappers/mod_rewrite.c (working copy) @@ -517,7 +517,7 @@ static unsigned is_absolute_uri(char *uri, int *su switch (*uri++) { case 'a': case 'A': - if (!strncasecmp(uri, "jp://", 5)) { /* ajp:// */ + if (!ap_casecmpstrn(uri, "jp://", 5)) { /* ajp:// */ *sqs = 1; return 6; } @@ -525,7 +525,7 @@ static unsigned is_absolute_uri(char *uri, int *su case 'b': case 'B': - if (!strncasecmp(uri, "alancer://", 10)) { /* balancer:// */ + if (!ap_casecmpstrn(uri, "alancer://", 10)) { /* balancer:// */ *sqs = 1; return 11; } @@ -533,10 +533,10 @@ static unsigned is_absolute_uri(char *uri, int *su case 'f': case 'F': - if (!strncasecmp(uri, "tp://", 5)) { /* ftp:// */ + if (!ap_casecmpstrn(uri, "tp://", 5)) { /* ftp:// */ return 6; } - if (!strncasecmp(uri, "cgi://", 6)) { /* fcgi:// */ + if (!ap_casecmpstrn(uri, "cgi://", 6)) { /* fcgi:// */ *sqs = 1; return 7; } @@ -544,7 +544,7 @@ static unsigned is_absolute_uri(char *uri, int *su case 'g': case 'G': - if (!strncasecmp(uri, "opher://", 8)) { /* gopher:// */ + if (!ap_casecmpstrn(uri, "opher://", 8)) { /* gopher:// */ return 9; } break; @@ -551,11 +551,11 @@ static unsigned is_absolute_uri(char *uri, int *su case 'h': case 'H': - if (!strncasecmp(uri, "ttp://", 6)) { /* http:// */ + if (!ap_casecmpstrn(uri, "ttp://", 6)) { /* http:// */ *sqs = 1; return 7; } - else if (!strncasecmp(uri, "ttps://", 7)) { /* https:// */ + else if (!ap_casecmpstrn(uri, "ttps://", 7)) { /* https:// */ *sqs = 1; return 8; } @@ -563,7 +563,7 @@ static unsigned is_absolute_uri(char *uri, int *su case 'l': case 'L': - if (!strncasecmp(uri, "dap://", 6)) { /* ldap:// */ + if (!ap_casecmpstrn(uri, "dap://", 6)) { /* ldap:// */ return 7; } break; @@ -570,7 +570,7 @@ static unsigned is_absolute_uri(char *uri, int *su case 'm': case 'M': - if (!strncasecmp(uri, "ailto:", 6)) { /* mailto: */ + if (!ap_casecmpstrn(uri, "ailto:", 6)) { /* mailto: */ *sqs = 1; return 7; } @@ -578,10 +578,10 @@ static unsigned is_absolute_uri(char *uri, int *su case 'n': case 'N': - if (!strncasecmp(uri, "ews:", 4)) { /* news: */ + if (!ap_casecmpstrn(uri, "ews:", 4)) { /* news: */ return 5; } - else if (!strncasecmp(uri, "ntp://", 6)) { /* nntp:// */ + else if (!ap_casecmpstrn(uri, "ntp://", 6)) { /* nntp:// */ return 7; } break; @@ -588,7 +588,7 @@ static unsigned is_absolute_uri(char *uri, int *su case 's': case 'S': - if (!strncasecmp(uri, "cgi://", 6)) { /* scgi:// */ + if (!ap_casecmpstrn(uri, "cgi://", 6)) { /* scgi:// */ *sqs = 1; return 7; } @@ -596,11 +596,11 @@ static unsigned is_absolute_uri(char *uri, int *su case 'w': case 'W': - if (!strncasecmp(uri, "s://", 4)) { /* ws:// */ + if (!ap_casecmpstrn(uri, "s://", 4)) { /* ws:// */ *sqs = 1; return 5; } - else if (!strncasecmp(uri, "ss://", 5)) { /* wss:// */ + else if (!ap_casecmpstrn(uri, "ss://", 5)) { /* wss:// */ *sqs = 1; return 6; } @@ -688,7 +688,7 @@ static char *escape_absolute_uri(apr_pool_t *p, ch * [dn ["?" [attributes] ["?" [scope] * ["?" [filter] ["?" extensions]]]]]] */ - if (!strncasecmp(uri, "ldap", 4)) { + if (!ap_casecmpstrn(uri, "ldap", 4)) { char *token[5]; int c = 0; @@ -783,7 +783,7 @@ static void reduce_uri(request_rec *r) cp = (char *)ap_http_scheme(r); l = strlen(cp); if ( strlen(r->filename) > l+3 - && strncasecmp(r->filename, cp, l) == 0 + && ap_casecmpstrn(r->filename, cp, l) == 0 && r->filename[l] == ':' && r->filename[l+1] == '/' && r->filename[l+2] == '/' ) { @@ -2543,14 +2543,14 @@ static void add_cookie(request_rec *r, char *s) : NULL, expires ? (exp_time ? exp_time : "") : NULL, - (secure && (!strcasecmp(secure, "true") + (secure && (!ap_casecmpstr(secure, "true") || !strcmp(secure, "1") - || !strcasecmp(secure, + || !ap_casecmpstr(secure, "secure"))) ? "; secure" : NULL, - (httponly && (!strcasecmp(httponly, "true") + (httponly && (!ap_casecmpstr(httponly, "true") || !strcmp(httponly, "1") - || !strcasecmp(httponly, + || !ap_casecmpstr(httponly, "HttpOnly"))) ? "; HttpOnly" : NULL, NULL); Index: modules/mappers/mod_vhost_alias.c =================================================================== --- modules/mappers/mod_vhost_alias.c (revision 1722143) +++ modules/mappers/mod_vhost_alias.c (working copy) @@ -152,7 +152,7 @@ static const char *vhost_alias_set(cmd_parms *cmd, } if (!ap_os_is_path_absolute(cmd->pool, map)) { - if (strcasecmp(map, "none")) { + if (ap_casecmpstr(map, "none")) { return "format string must be an absolute path, or 'none'"; } *pmap = NULL; Index: modules/metadata/mod_cern_meta.c =================================================================== --- modules/metadata/mod_cern_meta.c (revision 1722143) +++ modules/metadata/mod_cern_meta.c (working copy) @@ -240,7 +240,7 @@ static int scan_meta_file(request_rec *r, apr_file while (apr_isspace(*l)) ++l; - if (!strcasecmp(w, "Content-type")) { + if (!ap_casecmpstr(w, "Content-type")) { char *tmp; /* Nuke trailing whitespace */ @@ -252,7 +252,7 @@ static int scan_meta_file(request_rec *r, apr_file ap_content_type_tolower(tmp); ap_set_content_type(r, tmp); } - else if (!strcasecmp(w, "Status")) { + else if (!ap_casecmpstr(w, "Status")) { sscanf(l, "%d", &r->status); r->status_line = apr_pstrdup(r->pool, l); } Index: modules/metadata/mod_headers.c =================================================================== --- modules/metadata/mod_headers.c (revision 1722143) +++ modules/metadata/mod_headers.c (working copy) @@ -789,7 +789,7 @@ static int do_headers_fixup(request_rec *r, apr_ta } break; case hdr_set: - if (!strcasecmp(hdr->header, "Content-Type")) { + if (!ap_casecmpstr(hdr->header, "Content-Type")) { ap_set_content_type(r, process_tags(hdr, r)); } apr_table_setn(headers, hdr->header, process_tags(hdr, r)); @@ -796,7 +796,7 @@ static int do_headers_fixup(request_rec *r, apr_ta break; case hdr_setifempty: if (NULL == apr_table_get(headers, hdr->header)) { - if (!strcasecmp(hdr->header, "Content-Type")) { + if (!ap_casecmpstr(hdr->header, "Content-Type")) { ap_set_content_type(r, process_tags(hdr, r)); } apr_table_setn(headers, hdr->header, process_tags(hdr, r)); @@ -813,7 +813,7 @@ static int do_headers_fixup(request_rec *r, apr_ta break; case hdr_edit: case hdr_edit_r: - if (!strcasecmp(hdr->header, "Content-Type") && r->content_type) { + if (!ap_casecmpstr(hdr->header, "Content-Type") && r->content_type) { const char *repl = process_regexp(hdr, r->content_type, r); if (repl == NULL) return 0; Index: modules/proxy/ajp_header.c =================================================================== --- modules/proxy/ajp_header.c (revision 1722143) +++ modules/proxy/ajp_header.c (working copy) @@ -633,15 +633,15 @@ static apr_status_t ajp_unmarshal_response(ajp_msg } /* Set-Cookie need additional processing */ - if (!strcasecmp(stringname, "Set-Cookie")) { + if (!ap_casecmpstr(stringname, "Set-Cookie")) { value = ap_proxy_cookie_reverse_map(r, dconf, value); } /* Location, Content-Location, URI and Destination need additional * processing */ - else if (!strcasecmp(stringname, "Location") - || !strcasecmp(stringname, "Content-Location") - || !strcasecmp(stringname, "URI") - || !strcasecmp(stringname, "Destination")) + else if (!ap_casecmpstr(stringname, "Location") + || !ap_casecmpstr(stringname, "Content-Location") + || !ap_casecmpstr(stringname, "URI") + || !ap_casecmpstr(stringname, "Destination")) { value = ap_proxy_location_reverse_map(r, dconf, value); } @@ -654,7 +654,7 @@ static apr_status_t ajp_unmarshal_response(ajp_msg apr_table_add(r->headers_out, stringname, value); /* Content-type needs an additional handling */ - if (strcasecmp(stringname, "Content-Type") == 0) { + if (ap_casecmpstr(stringname, "Content-Type") == 0) { /* add corresponding filter */ ap_set_content_type(r, apr_pstrdup(r->pool, value)); ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r, Index: modules/proxy/mod_proxy.c =================================================================== --- modules/proxy/mod_proxy.c (revision 1722143) +++ modules/proxy/mod_proxy.c (working copy) @@ -512,7 +512,7 @@ static int proxy_detect(request_rec *r) if (conf->req && r->parsed_uri.scheme) { /* but it might be something vhosted */ if (!(r->parsed_uri.hostname - && !strcasecmp(r->parsed_uri.scheme, ap_http_scheme(r)) + && !ap_casecmpstr(r->parsed_uri.scheme, ap_http_scheme(r)) && ap_matches_request_vhost(r, r->parsed_uri.hostname, (apr_port_t)(r->parsed_uri.port_str ? r->parsed_uri.port : ap_default_port(r))))) { @@ -891,7 +891,7 @@ static int proxy_needsdomain(request_rec *r, const /* If host does contain a dot already, or it is "localhost", decline */ if (strchr(r->parsed_uri.hostname, '.') != NULL /* has domain, or IPv4 literal */ || strchr(r->parsed_uri.hostname, ':') != NULL /* IPv6 literal */ - || strcasecmp(r->parsed_uri.hostname, "localhost") == 0) + || ap_casecmpstr(r->parsed_uri.hostname, "localhost") == 0) return DECLINED; /* host name has a dot already */ ref = apr_table_get(r->headers_in, "Referer"); @@ -1097,9 +1097,9 @@ static int proxy_handler(request_rec *r) if (strcmp(ents[i].scheme, "*") == 0 || (ents[i].use_regex && ap_regexec(ents[i].regexp, url, 0, NULL, 0) == 0) || - (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) || + (p2 == NULL && ap_casecmpstr(scheme, ents[i].scheme) == 0) || (p2 != NULL && - strncasecmp(url, ents[i].scheme, + ap_casecmpstrn(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) { /* handle the scheme */ @@ -1490,7 +1490,7 @@ PROXY_DECLARE(const char *) ap_proxy_de_socketfy(a * We could be passed a URL during the config stage that contains * the UDS path... ignore it */ - if (!strncasecmp(url, "unix:", 5) && + if (!ap_casecmpstrn(url, "unix:", 5) && ((ptr = ap_strchr_c(url, '|')) != NULL)) { /* move past the 'unix:...|' UDS path info */ const char *ret, *c; Index: modules/proxy/mod_proxy_ajp.c =================================================================== --- modules/proxy/mod_proxy_ajp.c (revision 1722143) +++ modules/proxy/mod_proxy_ajp.c (working copy) @@ -35,7 +35,7 @@ static int proxy_ajp_canon(request_rec *r, char *u apr_port_t port, def_port; /* ap_port_of_scheme() */ - if (strncasecmp(url, "ajp:", 4) == 0) { + if (ap_casecmpstrn(url, "ajp:", 4) == 0) { url += 4; } else { @@ -245,7 +245,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, req /* read the first bloc of data */ input_brigade = apr_brigade_create(p, r->connection->bucket_alloc); tenc = apr_table_get(r->headers_in, "Transfer-Encoding"); - if (tenc && (strcasecmp(tenc, "chunked") == 0)) { + if (tenc && (ap_casecmpstr(tenc, "chunked") == 0)) { /* The AJP protocol does not want body data yet */ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00870) "request is chunked"); } else { @@ -734,7 +734,7 @@ static int proxy_ajp_handler(request_rec *r, proxy apr_pool_t *p = r->pool; apr_uri_t *uri; - if (strncasecmp(url, "ajp:", 4) != 0) { + if (ap_casecmpstrn(url, "ajp:", 4) != 0) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00894) "declining URL %s", url); return DECLINED; } Index: modules/proxy/mod_proxy_balancer.c =================================================================== --- modules/proxy/mod_proxy_balancer.c (revision 1722143) +++ modules/proxy/mod_proxy_balancer.c (working copy) @@ -63,7 +63,7 @@ static int proxy_balancer_canon(request_rec *r, ch apr_port_t port = 0; /* TODO: offset of BALANCER_PREFIX ?? */ - if (strncasecmp(url, "balancer:", 9) == 0) { + if (ap_casecmpstrn(url, "balancer:", 9) == 0) { url += 9; } else { @@ -1378,7 +1378,7 @@ static int balancer_handler(request_rec *r) ap_rprintf(r, " <httpd:lbset>%d</httpd:lbset>\n", worker->s->lbset); /* End proxy_worker_stat */ - if (!strcasecmp(worker->s->scheme, "ajp")) { + if (!ap_casecmpstr(worker->s->scheme, "ajp")) { ap_rputs(" <httpd:flushpackets>", r); switch (worker->s->flush_packets) { case flush_off: Index: modules/proxy/mod_proxy_fcgi.c =================================================================== --- modules/proxy/mod_proxy_fcgi.c (revision 1722143) +++ modules/proxy/mod_proxy_fcgi.c (working copy) @@ -39,7 +39,7 @@ static int proxy_fcgi_canon(request_rec *r, char * fcgi_req_config_t *rconf = NULL; const char *pathinfo_type = NULL; - if (strncasecmp(url, "fcgi:", 5) == 0) { + if (ap_casecmpstrn(url, "fcgi:", 5) == 0) { url += 5; } else { @@ -878,7 +878,7 @@ static int proxy_fcgi_handler(request_rec *r, prox "url: %s proxyname: %s proxyport: %d", url, proxyname, proxyport); - if (strncasecmp(url, "fcgi:", 5) != 0) { + if (ap_casecmpstrn(url, "fcgi:", 5) != 0) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01077) "declining URL %s", url); return DECLINED; } Index: modules/proxy/mod_proxy_fdpass.c =================================================================== --- modules/proxy/mod_proxy_fdpass.c (revision 1722143) +++ modules/proxy/mod_proxy_fdpass.c (working copy) @@ -32,7 +32,7 @@ static int proxy_fdpass_canon(request_rec *r, char { const char *path; - if (strncasecmp(url, "fd://", 5) == 0) { + if (ap_casecmpstrn(url, "fd://", 5) == 0) { url += 5; } else { @@ -129,7 +129,7 @@ static int proxy_fdpass_handler(request_rec *r, pr apr_socket_t *sock; apr_socket_t *clientsock; - if (strncasecmp(url, "fd://", 5) == 0) { + if (ap_casecmpstrn(url, "fd://", 5) == 0) { url += 5; } else { Index: modules/proxy/mod_proxy_ftp.c =================================================================== --- modules/proxy/mod_proxy_ftp.c (revision 1722143) +++ modules/proxy/mod_proxy_ftp.c (working copy) @@ -294,7 +294,7 @@ static int proxy_ftp_canon(request_rec *r, char *u apr_port_t port, def_port; /* */ - if (strncasecmp(url, "ftp:", 4) == 0) { + if (ap_casecmpstrn(url, "ftp:", 4) == 0) { url += 4; } else { @@ -494,7 +494,7 @@ static apr_status_t proxy_send_dir_filter(ap_filte path = apr_uri_unparse(p, &f->r->parsed_uri, APR_URI_UNP_OMITSITEPART | APR_URI_UNP_OMITQUERY); /* If path began with /%2f, change the basedir */ - if (strncasecmp(path, "/%2f", 4) == 0) { + if (ap_casecmpstrn(path, "/%2f", 4) == 0) { basedir = "/%2f"; } @@ -1003,7 +1003,7 @@ static int proxy_ftp_handler(request_rec *r, proxy proxyhost); return DECLINED; /* proxy connections are via HTTP */ } - if (strncasecmp(url, "ftp:", 4)) { + if (ap_casecmpstrn(url, "ftp:", 4)) { ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r, "declining URL %s - not ftp:", url); return DECLINED; /* only interested in FTP */ @@ -1074,7 +1074,7 @@ static int proxy_ftp_handler(request_rec *r, proxy * still smaller that the URL is logged regularly. */ if ((password = apr_table_get(r->headers_in, "Authorization")) != NULL - && strcasecmp(ap_getword(r->pool, &password, ' '), "Basic") == 0 + && ap_casecmpstr(ap_getword(r->pool, &password, ' '), "Basic") == 0 && (password = ap_pbase64decode(r->pool, password))[0] != ':') { /* Check the decoded string for special characters. */ if (!ftp_check_string(password)) { @@ -1306,7 +1306,7 @@ static int proxy_ftp_handler(request_rec *r, proxy /* Special handling for leading "%2f": this enforces a "cwd /" * out of the $HOME directory which was the starting point after login */ - if (strncasecmp(path, "%2f", 3) == 0) { + if (ap_casecmpstrn(path, "%2f", 3) == 0) { path += 3; while (*path == '/') /* skip leading '/' (after root %2f) */ ++path; Index: modules/proxy/mod_proxy_http.c =================================================================== --- modules/proxy/mod_proxy_http.c (revision 1722143) +++ modules/proxy/mod_proxy_http.c (working copy) @@ -43,11 +43,11 @@ static int proxy_http_canon(request_rec *r, char * apr_port_t port, def_port; /* ap_port_of_scheme() */ - if (strncasecmp(url, "http:", 5) == 0) { + if (ap_casecmpstrn(url, "http:", 5) == 0) { url += 5; scheme = "http"; } - else if (strncasecmp(url, "https:", 6) == 0) { + else if (ap_casecmpstrn(url, "https:", 6) == 0) { url += 6; scheme = "https"; } @@ -765,7 +765,7 @@ int ap_proxy_http_request(apr_pool_t *p, request_r * encoding has been done by the extensions' handler, and * do not modify add_te_chunked's logic */ - if (old_te_val && strcasecmp(old_te_val, "chunked") != 0) { + if (old_te_val && ap_casecmpstr(old_te_val, "chunked") != 0) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01093) "%s Transfer-Encoding is not supported", old_te_val); return HTTP_INTERNAL_SERVER_ERROR; @@ -1047,7 +1047,7 @@ static void process_proxy_header(request_rec *r, p }; int i; for (i = 0; date_hdrs[i]; ++i) { - if (!strcasecmp(date_hdrs[i], key)) { + if (!ap_casecmpstr(date_hdrs[i], key)) { apr_table_add(r->headers_out, key, date_canon(r->pool, value)); return; @@ -1054,7 +1054,7 @@ static void process_proxy_header(request_rec *r, p } } for (i = 0; transform_hdrs[i].name; ++i) { - if (!strcasecmp(transform_hdrs[i].name, key)) { + if (!ap_casecmpstr(transform_hdrs[i].name, key)) { apr_table_add(r->headers_out, key, (*transform_hdrs[i].func)(r, c, value)); return; Index: modules/proxy/mod_proxy_scgi.c =================================================================== --- modules/proxy/mod_proxy_scgi.c (revision 1722143) +++ modules/proxy/mod_proxy_scgi.c (working copy) @@ -180,7 +180,7 @@ static int scgi_canon(request_rec *r, char *url) const char *err, *path; apr_port_t port, def_port; - if (strncasecmp(url, SCHEME "://", sizeof(SCHEME) + 2)) { + if (ap_casecmpstrn(url, SCHEME "://", sizeof(SCHEME) + 2)) { return DECLINED; } url += sizeof(SCHEME); /* Keep slashes */ @@ -434,7 +434,7 @@ static int pass_response(request_rec *r, proxy_con if (location && *location == '/') { scgi_request_config *req_conf = apr_palloc(r->pool, sizeof(*req_conf)); - if (strcasecmp(location_header, "Location")) { + if (ap_casecmpstr(location_header, "Location")) { if (err) { apr_table_unset(r->err_headers_out, location_header); } @@ -533,7 +533,7 @@ static int scgi_handler(request_rec *r, proxy_work apr_uri_t *uri = apr_palloc(r->pool, sizeof(*uri)); char dummy; - if (strncasecmp(url, SCHEME "://", sizeof(SCHEME) + 2)) { + if (ap_casecmpstrn(url, SCHEME "://", sizeof(SCHEME) + 2)) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00865) "declining URL %s", url); return DECLINED; Index: modules/proxy/mod_proxy_wstunnel.c =================================================================== --- modules/proxy/mod_proxy_wstunnel.c (revision 1722143) +++ modules/proxy/mod_proxy_wstunnel.c (working copy) @@ -33,12 +33,12 @@ static int proxy_wstunnel_canon(request_rec *r, ch apr_port_t port, def_port; /* ap_port_of_scheme() */ - if (strncasecmp(url, "ws:", 3) == 0) { + if (ap_casecmpstrn(url, "ws:", 3) == 0) { url += 3; scheme = "ws:"; def_port = apr_uri_port_of_scheme("http"); } - else if (strncasecmp(url, "wss:", 4) == 0) { + else if (ap_casecmpstrn(url, "wss:", 4) == 0) { url += 4; scheme = "wss:"; def_port = apr_uri_port_of_scheme("https"); @@ -323,11 +323,11 @@ static int proxy_wstunnel_handler(request_rec *r, apr_uri_t *uri; int is_ssl = 0; - if (strncasecmp(url, "wss:", 4) == 0) { + if (ap_casecmpstrn(url, "wss:", 4) == 0) { scheme = "WSS"; is_ssl = 1; } - else if (strncasecmp(url, "ws:", 3) == 0) { + else if (ap_casecmpstrn(url, "ws:", 3) == 0) { scheme = "WS"; } else { @@ -336,7 +336,7 @@ static int proxy_wstunnel_handler(request_rec *r, } upgrade = apr_table_get(r->headers_in, "Upgrade"); - if (!upgrade || strcasecmp(upgrade, "WebSocket") != 0) { + if (!upgrade || ap_casecmpstr(upgrade, "WebSocket") != 0) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02900) "declining URL %s (not WebSocket)", url); return DECLINED; Index: modules/proxy/proxy_util.c =================================================================== --- modules/proxy/proxy_util.c (revision 1722143) +++ modules/proxy/proxy_util.c (working copy) @@ -1081,7 +1081,7 @@ PROXY_DECLARE(int) ap_proxy_valid_balancer_name(ch { if (!i) i = sizeof(BALANCER_PREFIX)-1; - return (!strncasecmp(name, BALANCER_PREFIX, i)); + return (!ap_casecmpstrn(name, BALANCER_PREFIX, i)); } @@ -1634,7 +1634,7 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_p if (ptr) { *ptr = '\0'; rv = apr_uri_parse(p, url, &urisock); - if (rv == APR_SUCCESS && !strcasecmp(urisock.scheme, "unix")) { + if (rv == APR_SUCCESS && !ap_casecmpstr(urisock.scheme, "unix")) { sockpath = ap_runtime_dir_relative(p, urisock.path);; url = ptr+1; /* so we get the scheme for the uds */ } @@ -3233,7 +3233,7 @@ static int find_conn_headers(void *data, const cha val++; } name = ap_get_token(x->pool, &val, 0); - if (!strcasecmp(name, "close")) { + if (!ap_casecmpstr(name, "close")) { x->closed = 1; } if (!x->first) { @@ -3431,7 +3431,7 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_poo /* Add the Expect header if not already there. */ if (((val = apr_table_get(r->headers_in, "Expect")) == NULL) - || (strcasecmp(val, "100-Continue") != 0 /* fast path */ + || (ap_casecmpstr(val, "100-Continue") != 0 /* fast path */ && !ap_find_token(r->pool, val, "100-Continue"))) { apr_table_mergen(r->headers_in, "Expect", "100-Continue"); } @@ -3494,15 +3494,15 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_poo || headers_in[counter].val == NULL /* Already sent */ - || !strcasecmp(headers_in[counter].key, "Host") + || !ap_casecmpstr(headers_in[counter].key, "Host") /* Clear out hop-by-hop request headers not to send * RFC2616 13.5.1 says we should strip these headers */ - || !strcasecmp(headers_in[counter].key, "Keep-Alive") - || !strcasecmp(headers_in[counter].key, "TE") - || !strcasecmp(headers_in[counter].key, "Trailer") - || !strcasecmp(headers_in[counter].key, "Upgrade") + || !ap_casecmpstr(headers_in[counter].key, "Keep-Alive") + || !ap_casecmpstr(headers_in[counter].key, "TE") + || !ap_casecmpstr(headers_in[counter].key, "Trailer") + || !ap_casecmpstr(headers_in[counter].key, "Upgrade") ) { continue; @@ -3512,7 +3512,7 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_poo * If we have used it then MAYBE: RFC2616 says we MAY propagate it. * So let's make it configurable by env. */ - if (!strcasecmp(headers_in[counter].key,"Proxy-Authorization")) { + if (!ap_casecmpstr(headers_in[counter].key,"Proxy-Authorization")) { if (r->user != NULL) { /* we've authenticated */ if (!apr_table_get(r->subprocess_env, "Proxy-Chain-Auth")) { continue; @@ -3522,11 +3522,11 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_poo /* Skip Transfer-Encoding and Content-Length for now. */ - if (!strcasecmp(headers_in[counter].key, "Transfer-Encoding")) { + if (!ap_casecmpstr(headers_in[counter].key, "Transfer-Encoding")) { *old_te_val = headers_in[counter].val; continue; } - if (!strcasecmp(headers_in[counter].key, "Content-Length")) { + if (!ap_casecmpstr(headers_in[counter].key, "Content-Length")) { *old_cl_val = headers_in[counter].val; continue; } @@ -3533,11 +3533,11 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_poo /* for sub-requests, ignore freshness/expiry headers */ if (r->main) { - if ( !strcasecmp(headers_in[counter].key, "If-Match") - || !strcasecmp(headers_in[counter].key, "If-Modified-Since") - || !strcasecmp(headers_in[counter].key, "If-Range") - || !strcasecmp(headers_in[counter].key, "If-Unmodified-Since") - || !strcasecmp(headers_in[counter].key, "If-None-Match")) { + if ( !ap_casecmpstr(headers_in[counter].key, "If-Match") + || !ap_casecmpstr(headers_in[counter].key, "If-Modified-Since") + || !ap_casecmpstr(headers_in[counter].key, "If-Range") + || !ap_casecmpstr(headers_in[counter].key, "If-Unmodified-Since") + || !ap_casecmpstr(headers_in[counter].key, "If-None-Match")) { continue; } } @@ -3622,7 +3622,7 @@ PROXY_DECLARE(apr_port_t) ap_proxy_port_of_scheme( } else { proxy_schemes_t *pscheme; for (pscheme = pschemes; pscheme->name != NULL; ++pscheme) { - if (strcasecmp(scheme, pscheme->name) == 0) { + if (ap_casecmpstr(scheme, pscheme->name) == 0) { return pscheme->default_port; } } Index: modules/ssl/ssl_engine_ocsp.c =================================================================== --- modules/ssl/ssl_engine_ocsp.c (revision 1722143) +++ modules/ssl/ssl_engine_ocsp.c (working copy) @@ -86,7 +86,7 @@ static apr_uri_t *determine_responder_uri(SSLSrvCo return NULL; } - if (strcasecmp(u->scheme, "http") != 0) { + if (ap_casecmpstr(u->scheme, "http") != 0) { ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(01920) "cannot handle OCSP responder URI '%s'", s); return NULL; Index: server/log.c =================================================================== --- server/log.c (revision 1722143) +++ server/log.c (working copy) @@ -658,7 +658,7 @@ static int log_log_id(const ap_errorlog_info *info * c: log conn log id if available and not a once-per-request log line * else: log request log id if available */ - if (arg && !strcasecmp(arg, "c")) { + if (arg && (*arg == 'c' || *arg == 'C')) { if (info->c && (*arg != 'C' || !info->r)) { return cpystrn(buf, info->c->log_id, buflen); } Index: server/mpm_unix.c =================================================================== --- server/mpm_unix.c (revision 1722143) +++ server/mpm_unix.c (working copy) @@ -627,7 +627,7 @@ static apr_status_t dummy_connection(ap_pod_t *pod * expensive to do correctly (performing a complete SSL handshake) * or cause log spam by doing incorrectly (simply sending EOF). */ lp = ap_listeners; - while (lp && lp->protocol && strcasecmp(lp->protocol, "http") != 0) { + while (lp && lp->protocol && ap_casecmpstr(lp->protocol, "http") != 0) { lp = lp->next; } if (!lp) { @@ -675,7 +675,7 @@ static apr_status_t dummy_connection(ap_pod_t *pod return rv; } - if (lp->protocol && strcasecmp(lp->protocol, "https") == 0) { + if (lp->protocol && ap_casecmpstr(lp->protocol, "https") == 0) { /* Send a TLS 1.0 close_notify alert. This is perhaps the * "least wrong" way to open and cleanly terminate an SSL * connection. It should "work" without noisy error logs if Index: server/protocol.c =================================================================== --- server/protocol.c (revision 1722143) +++ server/protocol.c (working copy) @@ -520,7 +520,7 @@ AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, if (status == APR_SUCCESS) { /* if it has a scheme we may need to do absoluteURI vhost stuff */ if (r->parsed_uri.scheme - && !strcasecmp(r->parsed_uri.scheme, ap_http_scheme(r))) { + && !ap_casecmpstr(r->parsed_uri.scheme, ap_http_scheme(r))) { r->hostname = r->parsed_uri.hostname; } else if (r->method_number == M_CONNECT) { @@ -660,7 +660,7 @@ static int read_request_line(request_rec *r, apr_b r->proto_num = HTTP_VERSION(pro[5] - '0', pro[7] - '0'); } else if (3 == sscanf(r->protocol, "%4s/%u.%u", http, &major, &minor) - && (strcasecmp("http", http) == 0) + && (ap_casecmpstr("http", http) == 0) && (minor < HTTP_VERSION(1, 0)) ) /* don't allow HTTP/0.1000 */ r->proto_num = HTTP_VERSION(major, minor); else @@ -1036,7 +1036,7 @@ request_rec *ap_read_request(conn_rec *conn) * the final encoding ...; the server MUST respond with the 400 * (Bad Request) status code and then close the connection". */ - if (!(strcasecmp(tenc, "chunked") == 0 /* fast path */ + if (!(ap_casecmpstr(tenc, "chunked") == 0 /* fast path */ || ap_find_last_token(r->pool, tenc, "chunked"))) { ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02539) "client sent unknown Transfer-Encoding " @@ -1140,7 +1140,7 @@ request_rec *ap_read_request(conn_rec *conn) * unfortunately, to signal a poor man's mandatory extension that * the server must understand or return 417 Expectation Failed. */ - if (strcasecmp(expect, "100-continue") == 0) { + if (ap_casecmpstr(expect, "100-continue") == 0) { r->expecting_100 = 1; } else { @@ -1293,7 +1293,7 @@ AP_DECLARE(int) ap_get_basic_auth_pw(request_rec * : "Authorization"); const char *t; - if (!(t = ap_auth_type(r)) || strcasecmp(t, "Basic")) + if (!(t = ap_auth_type(r)) || ap_casecmpstr(t, "Basic")) return DECLINED; if (!ap_auth_name(r)) { @@ -1307,7 +1307,7 @@ AP_DECLARE(int) ap_get_basic_auth_pw(request_rec * return HTTP_UNAUTHORIZED; } - if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) { + if (ap_casecmpstr(ap_getword(r->pool, &auth_line, ' '), "Basic")) { /* Client tried to authenticate using wrong auth scheme */ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(00573) "client used wrong authentication scheme: %s", r->uri); Index: server/util.c =================================================================== --- server/util.c (revision 1722143) +++ server/util.c (working copy) @@ -96,7 +96,6 @@ #undef APLOG_MODULE_INDEX #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX - /* * Examine a field value (such as a media-/content-type) string and return * it sans any parameters; e.g., strip off any ';charset=foo' and the like. @@ -881,7 +880,7 @@ AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_confi if (finfo.filetype != APR_REG && #if defined(WIN32) || defined(OS2) || defined(NETWARE) - strcasecmp(apr_filepath_name_get(name), "nul") != 0) { + ap_casecmpstr(apr_filepath_name_get(name), "nul") != 0) { #else strcmp(name, "/dev/null") != 0) { #endif /* WIN32 || OS2 */ @@ -1609,7 +1608,7 @@ AP_DECLARE(int) ap_find_token(apr_pool_t *p, const while (*s && !TEST_CHAR(*s, T_HTTP_TOKEN_STOP)) { ++s; } - if (!strncasecmp((const char *)start_token, (const char *)tok, + if (!ap_casecmpstrn((const char *)start_token, (const char *)tok, s - start_token)) { return 1; } @@ -1636,7 +1635,7 @@ AP_DECLARE(int) ap_find_last_token(apr_pool_t *p, (lidx > 0 && !(apr_isspace(line[lidx - 1]) || line[lidx - 1] == ','))) return 0; - return (strncasecmp(&line[lidx], tok, tlen) == 0); + return (ap_casecmpstrn(&line[lidx], tok, tlen) == 0); } AP_DECLARE(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *str) @@ -2589,7 +2588,7 @@ AP_DECLARE(int) ap_parse_form_data(request_rec *r, /* sanity check - we only support forms for now */ ct = apr_table_get(r->headers_in, "Content-Type"); - if (!ct || strncasecmp("application/x-www-form-urlencoded", ct, 33)) { + if (!ct || ap_casecmpstrn("application/x-www-form-urlencoded", ct, 33)) { return ap_discard_request_body(r); } @@ -3119,3 +3118,119 @@ AP_DECLARE(int) ap_array_str_contains(const apr_ar return (ap_array_str_index(array, s, 0) >= 0); } +/* + * Provide our own known-fast implementation of str[n]casecmp() + * NOTE: Only ASCII alpha characters 41-5A are folded to 61-7A, + * other 8-bit latin alphabetics are never case-folded! + */ +static const unsigned char ucharmap[] = { + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, + 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; + +#else /* APR_CHARSET_EBCDIC */ +/* Derived from apr-iconv/ccs/cp037.c for EBCDIC case comparison, + provides unique identity of every char value (strict ISO-646 + conformance, arbitrary election of an ISO-8859-1 ordering, and + very arbitrary control code assignments into C1 to achieve + identity and a reversible mapping of code points), + then folding the equivalences of ASCII 41-5A into 61-7A, + presenting comparison results in a somewhat ISO/IEC 10646 + (ASCII-like) order, depending on the EBCDIC code page in use. + */ +static const unsigned char ucharmap[] = { + 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, + 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, + 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, + 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, + 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, + 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, + 0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, + 0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, + 0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, + 0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAC, + 0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, + 0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, + 0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, + 0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, + 0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, + 0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, + 0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, + 0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0xDD, 0xDE, 0xAE, + 0x5E, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, + 0xBD, 0xBE, 0x5B, 0x5D, 0xAF, 0xA8, 0xB4, 0xD7, + 0x7B, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, + 0x7D, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, + 0x71, 0x72, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, + 0x5C, 0xF7, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F +}; +#endif + +AP_DECLARE(int) ap_casecmpstr(const char *s1, const char *s2) +{ + const unsigned char *ps1 = (const unsigned char *) s1; + const unsigned char *ps2 = (const unsigned char *) s2; + + while (ucharmap[*ps1] == ucharmap[*ps2++]) { + if (*ps1++ == '\0') { + return (0); + } + } + return (ucharmap[*ps1] - ucharmap[*--ps2]); +} + +AP_DECLARE(int) ap_casecmpstrn(const char *s1, const char *s2, apr_size_t n) +{ + const unsigned char *ps1 = (const unsigned char *) s1; + const unsigned char *ps2 = (const unsigned char *) s2; + if (n) { + do { + if (ucharmap[*ps1] != ucharmap[*ps2++]) { + return (ucharmap[*ps1] - ucharmap[*--ps2]); + } + if (*ps1++ == '\0') { + /* we know both end here */ + return (0); + } + } while (!--n); + } + return (0); +} Index: server/util_expr_eval.c =================================================================== --- server/util_expr_eval.c (revision 1722143) +++ server/util_expr_eval.c (working copy) @@ -1682,7 +1682,7 @@ static int core_expr_lookup(ap_expr_lookup_parms * while (prov->func) { const char **name = prov->names; while (*name) { - if (strcasecmp(*name, parms->name) == 0) { + if (ap_casecmpstr(*name, parms->name) == 0) { *parms->func = prov->func; *parms->data = name; return OK; @@ -1715,7 +1715,7 @@ static int core_expr_lookup(ap_expr_lookup_parms * if (parms->type == AP_EXPR_FUNC_OP_UNARY) match = !strcmp(prov->name, parms->name); else - match = !strcasecmp(prov->name, parms->name); + match = !ap_casecmpstr(prov->name, parms->name); if (match) { if ((parms->flags & AP_EXPR_FLAG_RESTRICTED) && prov->restricted) { Index: server/util_script.c =================================================================== --- server/util_script.c (revision 1722143) +++ server/util_script.c (working copy) @@ -176,10 +176,10 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r * for no particular reason. */ - if (!strcasecmp(hdrs[i].key, "Content-type")) { + if (!ap_casecmpstr(hdrs[i].key, "Content-type")) { apr_table_addn(e, "CONTENT_TYPE", hdrs[i].val); } - else if (!strcasecmp(hdrs[i].key, "Content-length")) { + else if (!ap_casecmpstr(hdrs[i].key, "Content-length")) { apr_table_addn(e, "CONTENT_LENGTH", hdrs[i].val); } /* @@ -188,8 +188,8 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r * in the environment with "ps -e". But, if you must... */ #ifndef SECURITY_HOLE_PASS_AUTHORIZATION - else if (!strcasecmp(hdrs[i].key, "Authorization") - || !strcasecmp(hdrs[i].key, "Proxy-Authorization")) { + else if (!ap_casecmpstr(hdrs[i].key, "Authorization") + || !ap_casecmpstr(hdrs[i].key, "Proxy-Authorization")) { if (conf->cgi_pass_auth == AP_CGI_PASS_AUTH_ON) { add_unless_null(e, http2env(r, hdrs[i].key), hdrs[i].val); } @@ -593,7 +593,7 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex( ++l; } - if (!strcasecmp(w, "Content-type")) { + if (!ap_casecmpstr(w, "Content-type")) { char *tmp; /* Nuke trailing whitespace */ @@ -611,7 +611,7 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex( * If the script returned a specific status, that's what * we'll use - otherwise we assume 200 OK. */ - else if (!strcasecmp(w, "Status")) { + else if (!ap_casecmpstr(w, "Status")) { r->status = cgi_status = atoi(l); if (!ap_is_HTTP_VALID_RESPONSE(cgi_status)) ap_log_rerror(SCRIPT_LOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r, @@ -624,19 +624,19 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex( apr_filepath_name_get(r->filename), l); r->status_line = apr_pstrdup(r->pool, l); } - else if (!strcasecmp(w, "Location")) { + else if (!ap_casecmpstr(w, "Location")) { apr_table_set(r->headers_out, w, l); } - else if (!strcasecmp(w, "Content-Length")) { + else if (!ap_casecmpstr(w, "Content-Length")) { apr_table_set(r->headers_out, w, l); } - else if (!strcasecmp(w, "Content-Range")) { + else if (!ap_casecmpstr(w, "Content-Range")) { apr_table_set(r->headers_out, w, l); } - else if (!strcasecmp(w, "Transfer-Encoding")) { + else if (!ap_casecmpstr(w, "Transfer-Encoding")) { apr_table_set(r->headers_out, w, l); } - else if (!strcasecmp(w, "ETag")) { + else if (!ap_casecmpstr(w, "ETag")) { apr_table_set(r->headers_out, w, l); } /* @@ -643,11 +643,11 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex( * If the script gave us a Last-Modified header, we can't just * pass it on blindly because of restrictions on future values. */ - else if (!strcasecmp(w, "Last-Modified")) { + else if (!ap_casecmpstr(w, "Last-Modified")) { ap_update_mtime(r, apr_date_parse_http(l)); ap_set_last_modified(r); } - else if (!strcasecmp(w, "Set-Cookie")) { + else if (!ap_casecmpstr(w, "Set-Cookie")) { apr_table_add(cookie_table, w, l); } else { Index: . =================================================================== --- . (revision 1722143) +++ . (working copy) Property changes on: . ___________________________________________________________________ Modified: svn:mergeinfo Merged /httpd/httpd/trunk:r1715401,1715404,1715527,1715546,1715554,1715587,1715632,1715736,1715852,1715876,1715880,1715938,1716151,1722150