Browse Source

[core] prefer buffer_append_string_len()

prefer buffer_append_string_len() when string len is known
(instead of buffer_append_string() which will recalculate strlen)
personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
65fcd7810f
  1. 2
      src/configparser.y
  2. 8
      src/http-header-glue.c
  3. 2
      src/mod_auth.c
  4. 10
      src/mod_authn_gssapi.c

2
src/configparser.y

@ -566,7 +566,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
b = buffer_init();
buffer_copy_buffer(b, ctx->current->key);
buffer_append_string(b, "/");
buffer_append_string_len(b, CONST_STR_LEN("/"));
buffer_append_string_buffer(b, B);
buffer_append_string_buffer(b, C);
buffer_append_string_buffer(b, op);

8
src/http-header-glue.c

@ -206,7 +206,7 @@ static int http_response_parse_range(server *srv, connection *con, buffer *path,
int error;
off_t start, end;
const char *s, *minus;
char *boundary = "fkj49sn38dcn3";
static const char boundary[] = "fkj49sn38dcn3";
buffer *content_type = http_header_response_get(con, HTTP_HEADER_CONTENT_TYPE, CONST_STR_LEN("Content-Type"));
start = 0;
@ -328,7 +328,7 @@ static int http_response_parse_range(server *srv, connection *con, buffer *path,
buffer *b = buffer_init();
buffer_copy_string_len(b, CONST_STR_LEN("\r\n--"));
buffer_append_string(b, boundary);
buffer_append_string_len(b, boundary, sizeof(boundary)-1);
/* write Content-Range */
buffer_append_string_len(b, CONST_STR_LEN("\r\nContent-Range: bytes "));
@ -364,7 +364,7 @@ static int http_response_parse_range(server *srv, connection *con, buffer *path,
buffer *b = buffer_init();
buffer_copy_string_len(b, "\r\n--", 4);
buffer_append_string(b, boundary);
buffer_append_string_len(b, boundary, sizeof(boundary)-1);
buffer_append_string_len(b, "--\r\n", 4);
con->response.content_length += buffer_string_length(b);
@ -374,7 +374,7 @@ static int http_response_parse_range(server *srv, connection *con, buffer *path,
/* set header-fields */
buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("multipart/byteranges; boundary="));
buffer_append_string(srv->tmp_buf, boundary);
buffer_append_string_len(srv->tmp_buf, boundary, sizeof(boundary)-1);
/* overwrite content-type */
http_header_response_set(con, HTTP_HEADER_CONTENT_TYPE, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(srv->tmp_buf));

2
src/mod_auth.c

@ -861,7 +861,7 @@ static handler_t mod_auth_send_401_unauthorized_digest(server *srv, connection *
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("\", charset=\"UTF-8\", nonce=\""));
buffer_append_uint_hex(srv->tmp_buf, (uintmax_t)srv->cur_ts);
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(":"));
buffer_append_string(srv->tmp_buf, hh);
buffer_append_string_len(srv->tmp_buf, hh, HASHHEXLEN);
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("\", qop=\"auth\""));
if (nonce_stale) {
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(", stale=true"));

10
src/mod_authn_gssapi.c

@ -193,9 +193,9 @@ static void mod_authn_gssapi_log_gss_error(server *srv, const char *file, unsign
maj_stat = gss_display_status(&min_stat, err_min, GSS_C_MECH_CODE,
GSS_C_NULL_OID, &msg_ctx, &status_string);
if (!GSS_ERROR(maj_stat)) {
buffer_append_string(msg, " (");
buffer_append_string_len(msg, CONST_STR_LEN(" ("));
buffer_append_string(msg, status_string.value);
buffer_append_string(msg, ")");
buffer_append_string_len(msg, CONST_STR_LEN(")"));
gss_release_buffer(&min_stat, &status_string);
}
} while (!GSS_ERROR(maj_stat) && msg_ctx != 0);
@ -365,12 +365,12 @@ static handler_t mod_authn_gssapi_check_spnego(server *srv, connection *con, plu
* ??? What if con->server_name is not set?
* ??? Will this work below if IPv6 provided in Host? probably not */
if (!buffer_is_empty(con->request.http_host)) {
buffer_append_string(sprinc, "/");
buffer_append_string_len(sprinc, CONST_STR_LEN("/"));
buffer_append_string_len(sprinc, con->request.http_host->ptr, strcspn(con->request.http_host->ptr, ":"));
}
}
if (strchr(sprinc->ptr, '@') == NULL) {
buffer_append_string(sprinc, "@");
buffer_append_string_len(sprinc, CONST_STR_LEN("@"));
buffer_append_string_buffer(sprinc, require->realm);
}
/*#define GSS_C_NT_USER_NAME gss_nt_user_name*/
@ -663,7 +663,7 @@ static handler_t mod_authn_gssapi_basic(server *srv, connection *con, void *p_d,
* ??? What if con->server_name is not set?
* ??? Will this work below if IPv6 provided in Host? probably not */
if (!buffer_is_empty(con->request.http_host)) {
buffer_append_string(sprinc, "/");
buffer_append_string_len(sprinc, CONST_STR_LEN("/"));
buffer_append_string_len(sprinc, con->request.http_host->ptr, strcspn(con->request.http_host->ptr, ":"));
}
}

Loading…
Cancel
Save