[multiple] replace strcasecmp() on short strings

personal/stbuehler/ci-build
Glenn Strauss 3 years ago
parent e3874a20ba
commit fc42ec12d9
  1. 6
      src/buffer.c
  2. 8
      src/mod_auth.c
  3. 6
      src/mod_extforward.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_" */
}

@ -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");

@ -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) {

Loading…
Cancel
Save