summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-06-04 21:45:44 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2019-06-06 02:48:43 -0400
commitfc42ec12d96157173a549a0b9706f4b869b0f431 (patch)
tree30fdeb8e34411222d62a42226a1eb2d909d2fe90
parente3874a20ba9dba307d99754c1e68d056f44c726c (diff)
downloadlighttpd1.4-fc42ec12d96157173a549a0b9706f4b869b0f431.zip
lighttpd1.4-fc42ec12d96157173a549a0b9706f4b869b0f431.tar.gz
[multiple] replace strcasecmp() on short strings
-rw-r--r--src/buffer.c6
-rw-r--r--src/mod_auth.c8
-rw-r--r--src/mod_extforward.c6
3 files changed, 12 insertions, 8 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 068a9aa..5a66588 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -716,7 +716,11 @@ void buffer_copy_string_encoded_cgi_varnames(buffer *b, const char *s, size_t s_
buffer_string_prepare_copy(b, s_len + 5);
- if (is_http_header && NULL != s && 0 != strcasecmp(s, "CONTENT-TYPE")) {
+ if (is_http_header) {
+ if (s_len == 12 && buffer_eq_icase_ssn(s, "Content-Type", 12)) {
+ buffer_copy_string_len(b, CONST_STR_LEN("CONTENT_TYPE"));
+ return;
+ }
buffer_copy_string_len(b, CONST_STR_LEN("HTTP_"));
j = 5; /* "HTTP_" */
}
diff --git a/src/mod_auth.c b/src/mod_auth.c
index 5dcdfd2..90be727 100644
--- a/src/mod_auth.c
+++ b/src/mod_auth.c
@@ -637,7 +637,7 @@ static void mod_auth_digest_mutate_sha256(http_auth_info_t *ai, const char *m, c
SHA256_Update(&ctx, (unsigned char *)uri, strlen(uri));
#if 0
/* qop=auth-int not supported, already checked in caller */
- if (qop && strcasecmp(qop, "auth-int") == 0) {
+ if (qop && buffer_eq_icase_ss(qop, strlen(qop), CONST_STR_LEN("auth-int"))){
SHA256_Update(&ctx, CONST_STR_LEN(":"));
SHA256_Update(&ctx, (unsigned char *) [body checksum], ai->dlen*2);
}
@@ -705,7 +705,7 @@ static void mod_auth_digest_mutate_sha512_256(http_auth_info_t *ai, const char *
SHA512_256_Update(&ctx, (unsigned char *)uri, strlen(uri));
#if 0
/* qop=auth-int not supported, already checked in caller */
- if (qop && strcasecmp(qop, "auth-int") == 0) {
+ if (qop && buffer_eq_icase_ss(qop, strlen(qop), CONST_STR_LEN("auth-int"))){
SHA512_256_Update(&ctx, CONST_STR_LEN(":"));
SHA512_256_Update(&ctx, (unsigned char *)[body checksum], ai->dlen*2);
}
@@ -777,7 +777,7 @@ static void mod_auth_digest_mutate_md5(http_auth_info_t *ai, const char *m, cons
li_MD5_Update(&ctx, (unsigned char *)uri, strlen(uri));
#if 0
/* qop=auth-int not supported, already checked in caller */
- if (qop && strcasecmp(qop, "auth-int") == 0) {
+ if (qop && buffer_eq_icase_ss(qop, strlen(qop), CONST_STR_LEN("auth-int"))){
li_MD5_Update(&ctx, CONST_STR_LEN(":"));
li_MD5_Update(&ctx, (unsigned char *) [body checksum], ai->dlen*2);
}
@@ -1055,7 +1055,7 @@ static handler_t mod_auth_check_digest(server *srv, connection *con, void *p_d,
}
}
- if (qop && strcasecmp(qop, "auth-int") == 0) {
+ if (qop && buffer_eq_icase_ss(qop, strlen(qop), CONST_STR_LEN("auth-int"))){
log_error_write(srv, __FILE__, __LINE__, "s",
"digest: qop=auth-int not supported");
diff --git a/src/mod_extforward.c b/src/mod_extforward.c
index 321ec23..b53e0d5 100644
--- a/src/mod_extforward.c
+++ b/src/mod_extforward.c
@@ -228,12 +228,12 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
if (array_get_element(config->value, "extforward.forwarder")) {
const data_string * const allds = (data_string *)array_get_element(s->forwarder, "all");
- s->forward_all = (NULL == allds) ? 0 : (0 == strcasecmp(allds->value->ptr, "trust")) ? 1 : -1;
+ s->forward_all = (NULL == allds) ? 0 : buffer_eq_icase_slen(allds->value, CONST_STR_LEN("trust")) ? 1 : -1;
for (size_t j = 0; j < s->forwarder->used; ++j) {
data_string * const ds = (data_string *)s->forwarder->data[j];
char * const nm_slash = strchr(ds->key->ptr, '/');
- if (0 != strcasecmp(ds->value->ptr, "trust")) {
- if (0 != strcasecmp(ds->value->ptr, "untrusted")) {
+ if (!buffer_eq_icase_slen(ds->value, CONST_STR_LEN("trust"))) {
+ if (!buffer_eq_icase_slen(ds->value, CONST_STR_LEN("untrusted"))) {
log_error_write(srv, __FILE__, __LINE__, "sbsbs", "ERROR: expect \"trust\", not \"", ds->key, "\" => \"", ds->value, "\"; treating as untrusted");
}
if (NULL != nm_slash) {