[multiple] use buffer_append_char()

master
Glenn Strauss 7 months ago
parent 1194e6d24b
commit f2610d23e2
  1. 4
      src/configfile.c
  2. 4
      src/http-header-glue.c
  3. 11
      src/http_etag.c
  4. 2
      src/http_kv.c
  5. 4
      src/http_range.c
  6. 4
      src/keyvalue.c
  7. 2
      src/log.c
  8. 2
      src/mod_ajp13.c
  9. 6
      src/mod_auth.c
  10. 4
      src/mod_authn_gssapi.c
  11. 16
      src/mod_authn_ldap.c
  12. 4
      src/mod_deflate.c
  13. 10
      src/mod_evhost.c
  14. 6
      src/mod_gnutls.c
  15. 6
      src/mod_magnet.c
  16. 2
      src/mod_nss.c
  17. 28
      src/mod_proxy.c
  18. 6
      src/mod_rrdtool.c
  19. 4
      src/mod_scgi.c
  20. 4
      src/mod_ssi.c
  21. 12
      src/mod_status.c
  22. 2
      src/mod_vhostdb_ldap.c
  23. 42
      src/mod_webdav.c
  24. 2
      src/network.c
  25. 2
      src/request.c
  26. 2
      src/server.c
  27. 8
      src/sock_addr.c

@ -1263,7 +1263,7 @@ int config_finalize(server *srv, const buffer *default_server_tag) {
b->ptr[0] = (dc->cond == CONFIG_COND_SUFFIX) ? '\\' : '^';
}
if (dc->cond != CONFIG_COND_PREFIX)
buffer_append_string_len(b, CONST_STR_LEN("$"));
buffer_append_char(b, '$');
dc->cond = CONFIG_COND_MATCH;
/*(config_pcre_keyvalue())*/
const int pcre_jit = config_feature_bool(srv, "server.pcre_jit", 1);
@ -2344,7 +2344,7 @@ int config_remoteip_normalize(buffer * const b, buffer * const tb) {
uint32_t len = buffer_clen(b); /*(save len before adding CIDR mask)*/
if (nm_bits) {
buffer_append_string_len(b, CONST_STR_LEN("/"));
buffer_append_char(b, '/');
buffer_append_int(b, (int)nm_bits);
}

@ -91,7 +91,7 @@ int http_response_buffer_append_authority(request_st * const r, buffer * const o
}
if (0 == listen_port) listen_port = r->con->srv->srvconf.port;
if (default_port != listen_port) {
buffer_append_string_len(o, CONST_STR_LEN(":"));
buffer_append_char(o, ':');
buffer_append_int(o, listen_port);
}
}
@ -124,7 +124,7 @@ int http_response_redirect_to_directory(request_st * const r, int status) {
buffer_copy_buffer(vb, o);
buffer_append_string_encoded(vb, BUF_PTR_LEN(&r->uri.path),
ENCODING_REL_URI);
buffer_append_string_len(vb, CONST_STR_LEN("/"));
buffer_append_char(vb, '/');
if (!buffer_is_blank(&r->uri.query))
buffer_append_str2(vb, CONST_STR_LEN("?"),
BUF_PTR_LEN(&r->uri.query));

@ -53,13 +53,16 @@ http_etag_remix (buffer * const etag, const char * const str, const uint32_t len
h = dekhash(etag->ptr+1, elen-2, h);
buffer_truncate(etag, 1);
}
else
buffer_copy_string_len(etag, CONST_STR_LEN("\""));
else {
buffer_clear(etag);
buffer_append_char(etag, '"');
}
#else
buffer_copy_string_len(etag, CONST_STR_LEN("\""));
/*buffer_clear(etag);*//*(currently always cleared in http_etag_create())*/
buffer_append_char(etag, '"');
#endif
buffer_append_int(etag, h);
buffer_append_string_len(etag, CONST_STR_LEN("\""));
buffer_append_char(etag, '"');
}
void

@ -212,7 +212,7 @@ void http_status_append(buffer * const b, const int status) {
buffer_append_string_len(b, kv->value, kv->vlen);
else {
buffer_append_int(b, status);
buffer_append_string_len(b, CONST_STR_LEN(" "));
buffer_append_char(b, ' ');
}
}

@ -246,9 +246,9 @@ http_range_multi (request_st * const r,
/* generate boundary-header including Content-Type and Content-Range */
buffer_truncate(tb, prefix_len);
buffer_append_int(tb, ranges[i]);
buffer_append_string_len(tb, CONST_STR_LEN("-"));
buffer_append_char(tb, '-');
buffer_append_int(tb, ranges[i+1]);
buffer_append_string_len(tb, CONST_STR_LEN("/"));
buffer_append_char(tb, '/');
buffer_append_int(tb, complete_length);
buffer_append_string_len(tb, CONST_STR_LEN("\r\n\r\n"));
if (c) /* single MEM_CHUNK in original cq; not using mem_min */

@ -322,10 +322,10 @@ static int pcre_keyvalue_buffer_subst_ext(buffer *b, const char *pattern, const
if (qs && !buffer_is_unset(qs)) {
if (NULL != strchr(b->ptr, '?')) {
if (!buffer_is_blank(qs))
buffer_append_string_len(b, CONST_STR_LEN("&"));
buffer_append_char(b, '&');
}
else {
buffer_append_string_len(b, CONST_STR_LEN("?"));
buffer_append_char(b, '?');
}
burl_append(b, BUF_PTR_LEN(qs), flags);
}

@ -230,7 +230,7 @@ static void
log_error_write (const log_error_st * const errh, buffer * const restrict b)
{
if (errh->mode != FDLOG_SYSLOG) { /* FDLOG_FD FDLOG_FILE FDLOG_PIPE */
buffer_append_string_len(b, CONST_STR_LEN("\n"));
buffer_append_char(b, '\n');
write_all(errh->fd, BUF_PTR_LEN(b));
}
else {

@ -694,7 +694,7 @@ ajp13_expand_headers (buffer * const b, handler_ctx * const hctx, uint32_t plen)
ptr += 2;
if (plen < len+1) break;
plen -= len+1; /* include -1 for ending '\0' */
buffer_append_string_len(b, " ", 1);
buffer_append_char(b, ' ');
if (len) buffer_append_string_len(b, (char *)ptr, len);
ptr += len+1;

@ -981,7 +981,7 @@ static void
mod_auth_append_nonce (buffer *b, unix_time64_t cur_ts, const struct http_auth_require_t *require, int dalgo, int *rndptr)
{
buffer_append_uint_hex(b, (uintmax_t)cur_ts);
buffer_append_string_len(b, CONST_STR_LEN(":"));
buffer_append_char(b, ':');
const buffer * const nonce_secret = require->nonce_secret;
int rnd;
if (NULL == nonce_secret)
@ -991,7 +991,7 @@ mod_auth_append_nonce (buffer *b, unix_time64_t cur_ts, const struct http_auth_r
? (void)(rnd = *rndptr)
: li_rand_pseudo_bytes((unsigned char *)&rnd, sizeof(rnd));
buffer_append_uint_hex(b, (uintmax_t)rnd);
buffer_append_string_len(b, CONST_STR_LEN(":"));
buffer_append_char(b, ':');
}
size_t n;
@ -1115,7 +1115,7 @@ mod_auth_digest_authentication_info (buffer *b, unix_time64_t cur_ts, const stru
buffer_clear(b);
buffer_append_string_len(b, CONST_STR_LEN("nextnonce=\""));
mod_auth_append_nonce(b, cur_ts, require, dalgo, NULL);
buffer_append_string_len(b, CONST_STR_LEN("\""));
buffer_append_char(b, '"');
}

@ -167,7 +167,7 @@ static void mod_authn_gssapi_log_gss_error(log_error_st *errh, const char *file,
gss_buffer_desc status_string;
buffer_copy_string(msg, func);
buffer_append_string_len(msg, CONST_STR_LEN("("));
buffer_append_char(msg, '(');
if (extra) buffer_append_string(msg, extra);
buffer_append_string_len(msg, CONST_STR_LEN("):"));
@ -185,7 +185,7 @@ static void mod_authn_gssapi_log_gss_error(log_error_st *errh, const char *file,
if (!GSS_ERROR(maj_stat)) {
buffer_append_string_len(msg, CONST_STR_LEN(" ("));
buffer_append_string(msg, status_string.value);
buffer_append_string_len(msg, CONST_STR_LEN(")"));
buffer_append_char(msg, ')');
gss_release_buffer(&min_stat, &status_string);
}
} while (!GSS_ERROR(maj_stat) && msg_ctx != 0);

@ -165,7 +165,7 @@ static void mod_authn_add_scheme (server *srv, buffer *host)
while (*e!=' '&&*e!='\t'&&*e!='\r'&&*e!='\n'&&*e!=','&&*e!='\0')
++e;
if (!buffer_is_blank(tb))
buffer_append_string_len(tb, CONST_STR_LEN(","));
buffer_append_char(tb, ',');
for (j = 0; j < sizeof(schemes)/sizeof(char *); ++j) {
if (buffer_eq_icase_ssn(b, schemes[j], strlen(schemes[j]))) {
break;
@ -374,7 +374,7 @@ static void mod_authn_append_ldap_dn_escape(buffer * const filter, const buffer
if (b[0] == ' ') { /* || b[0] == '#' handled below for MS Active Directory*/
/* escape leading ' ' */
buffer_append_string_len(filter, CONST_STR_LEN("\\"));
buffer_append_char(filter, '\\');
}
for (size_t i = 0; i < rlen; ++i) {
@ -406,8 +406,8 @@ static void mod_authn_append_ldap_dn_escape(buffer * const filter, const buffer
}
if (bs) {
buffer_append_string_len(filter, CONST_STR_LEN("\\"));
buffer_append_string_len(filter, b+i, 1);
buffer_append_char(filter, '\\');
buffer_append_char(filter, b[i]);
}
else {
/* escape NUL ('\0') (and all UTF-8 chars with high bit set) */
@ -422,7 +422,7 @@ static void mod_authn_append_ldap_dn_escape(buffer * const filter, const buffer
if (rlen > 1 && b[rlen-1] == ' ') {
/* escape trailing ' ' */
filter->ptr[buffer_clen(filter)-1] = '\\';
buffer_append_string_len(filter, CONST_STR_LEN(" "));
buffer_append_char(filter, ' ');
}
}
@ -681,16 +681,16 @@ static handler_t mod_authn_ldap_memberOf(log_error_st *errh, plugin_config *s, c
buffer *filter = buffer_init();
handler_t rc = HANDLER_ERROR;
buffer_copy_string_len(filter, CONST_STR_LEN("("));
buffer_append_char(filter, '(');
buffer_append_string_buffer(filter, s->auth_ldap_groupmember);
buffer_append_string_len(filter, CONST_STR_LEN("="));
buffer_append_char(filter, '=');
if (buffer_is_equal_string(s->auth_ldap_groupmember,
CONST_STR_LEN("member"))) {
buffer_append_string(filter, userdn);
} else { /*(assume "memberUid"; consider validating in SETDEFAULTS_FUNC)*/
mod_authn_append_ldap_filter_escape(filter, username);
}
buffer_append_string_len(filter, CONST_STR_LEN(")"));
buffer_append_char(filter, ')');
plugin_config_ldap * const ldc = s->ldc;
for (size_t i = 0; i < groups->used; ++i) {

@ -1963,7 +1963,7 @@ REQUEST_FUNC(mod_deflate_handle_response_start) {
/* modify ETag response header in-place to remove '"' and append '-label"' */
vb->ptr[etaglen-1] = '-'; /*(overwrite end '"')*/
buffer_append_string(vb, label);
buffer_append_string_len(vb, CONST_STR_LEN("\""));
buffer_append_char(vb, '"');
r->http_status = 304;
} else {
r->http_status = 412;
@ -1992,7 +1992,7 @@ REQUEST_FUNC(mod_deflate_handle_response_start) {
/* modify ETag response header in-place to remove '"' and append '-label"' */
vb->ptr[etaglen-1] = '-'; /*(overwrite end '"')*/
buffer_append_string(vb, label);
buffer_append_string_len(vb, CONST_STR_LEN("\""));
buffer_append_char(vb, '"');
}
/* set Content-Encoding to show selected compression type */

@ -256,7 +256,8 @@ static void mod_evhost_parse_host(buffer *key, array *host, buffer *authority) {
if(*ptr == '.') {
if (ptr != colon - 1) {
/* is something between the dots */
buffer_copy_string_len(key, CONST_STR_LEN("%"));
buffer_clear(key);
buffer_append_char(key, '%');
buffer_append_int(key, i++);
array_set_key_value(host, BUF_PTR_LEN(key), ptr+1, colon-ptr-1);
}
@ -266,7 +267,8 @@ static void mod_evhost_parse_host(buffer *key, array *host, buffer *authority) {
/* if the . is not the first character of the hostname */
if (colon != ptr) {
buffer_copy_string_len(key, CONST_STR_LEN("%"));
buffer_clear(key);
buffer_append_char(key, '%');
buffer_append_int(key, i /* ++ */);
array_set_key_value(host, BUF_PTR_LEN(key), ptr, colon-ptr);
}
@ -284,7 +286,7 @@ static void mod_evhost_build_doc_root_path(buffer *b, array *parsed_host, buffer
if (*(ptr+1) == '%') {
/* %% */
buffer_append_string_len(b, CONST_STR_LEN("%"));
buffer_append_char(b, '%');
} else if (*(ptr+1) == '_' ) {
/* %_ == full hostname */
char *colon = strchr(authority->ptr, ':');
@ -303,7 +305,7 @@ static void mod_evhost_build_doc_root_path(buffer *b, array *parsed_host, buffer
buffer_append_string_buffer(b, &ds->value);
} else {
if ((size_t)(ptr[4]-'0') <= buffer_clen(&ds->value)) {
buffer_append_string_len(b, ds->value.ptr+(ptr[4]-'0')-1, 1);
buffer_append_char(b, ds->value.ptr[(ptr[4]-'0')-1]);
}
}
} else {

@ -1858,7 +1858,7 @@ network_init_ssl (server *srv, plugin_config_socket *s, plugin_data *p)
if (NULL == s->priority_base) s->priority_base = "NORMAL";
buffer_copy_string_len(b, s->priority_base, strlen(s->priority_base));
if (!buffer_is_blank(&s->priority_str)) {
buffer_append_string_len(b, CONST_STR_LEN(":"));
buffer_append_char(b, ':');
uint32_t len = buffer_clen(&s->priority_str);
if (s->priority_str.ptr[len-1] == ':')
--len; /* remove trailing ':' */
@ -3421,9 +3421,9 @@ mod_gnutls_ssl_conf_curves(server *srv, plugin_config_socket *s, const buffer *c
continue;
}
buffer_append_string_len(plist, CONST_STR_LEN("+"));
buffer_append_char(plist, '+');
buffer_append_string_len(plist, names[i+1], strlen(names[i+1]));
buffer_append_string_len(plist, CONST_STR_LEN(":"));
buffer_append_char(plist, ':');
}
return 1;

@ -1224,12 +1224,12 @@ static int magnet_urlenc_query(lua_State *L) {
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
if (lua_isstring(L, -2)) {
if (!buffer_is_blank(b))
buffer_append_string_len(b, CONST_STR_LEN("&"));
buffer_append_char(b, '&');
s = magnet_checkconstbuffer(L, -2);
magnet_urlenc_query_part(b, s.ptr, s.len, 1);
if (!lua_isnil(L, -1)) {
s = magnet_checkconstbuffer(L, -1);
buffer_append_string_len(b, CONST_STR_LEN("="));
buffer_append_char(b, '=');
magnet_urlenc_query_part(b, s.ptr, s.len, 0);
}
}
@ -3066,7 +3066,7 @@ magnet_attract (request_st * const r, plugin_data * const p, script * const sc)
if (NULL == vb) {
vb =
http_header_env_set_ptr(r,CONST_STR_LEN("_L_MAGNET_RESTART"));
buffer_append_string_len(vb, "0", 1);
buffer_append_char(vb, '0');
}
result = HANDLER_COMEBACK;
if (++*vb->ptr-'0' >= 10) {

@ -2584,7 +2584,7 @@ https_add_ssl_client_verify_err (buffer * const b, unsigned int status)
const char *s = PR_ErrorToName(status);
if (s)
buffer_append_string_len(b, s, strlen(s));
buffer_append_string_len(b, CONST_STR_LEN(":"));
buffer_append_char(b, ':');
s = PR_ErrorToString(status, PR_LANGUAGE_I_DEFAULT);
buffer_append_string_len(b, s, strlen(s));
}

@ -506,7 +506,7 @@ static void http_header_remap_uri (buffer *b, size_t off, http_header_remap_opts
else {
alen = buffer_clen(b) - off;
if (0 == alen) return; /*(empty authority, e.g. "http:///")*/
buffer_append_string_len(b, CONST_STR_LEN("/"));
buffer_append_char(b, '/');
}
/* remap authority (if configured) and set offset to url-path */
@ -669,11 +669,11 @@ static void proxy_set_Forwarded(connection * const con, request_st * const r, co
int ipv6 = (NULL != strchr(efor->ptr, ':'));
ipv6
? buffer_append_string_len(b, CONST_STR_LEN("\"["))
: buffer_append_string_len(b, CONST_STR_LEN("\""));
: buffer_append_char(b, '"');
buffer_append_string_backslash_escaped(b, BUF_PTR_LEN(efor));
ipv6
? buffer_append_string_len(b, CONST_STR_LEN("]\""))
: buffer_append_string_len(b, CONST_STR_LEN("\""));
: buffer_append_char(b, '"');
} else if (family == AF_INET) {
/*(Note: if :port is added, then must be quoted-string:
* e.g. for="...:port")*/
@ -683,10 +683,10 @@ static void proxy_set_Forwarded(connection * const con, request_st * const r, co
BUF_PTR_LEN(&con->dst_addr_buf),
CONST_STR_LEN("]\""));
} else {
buffer_append_string_len(b, CONST_STR_LEN("\""));
buffer_append_char(b, '"');
buffer_append_string_backslash_escaped(
b, BUF_PTR_LEN(&con->dst_addr_buf));
buffer_append_string_len(b, CONST_STR_LEN("\""));
buffer_append_char(b, '"');
}
semicolon = 1;
}
@ -699,7 +699,7 @@ static void proxy_set_Forwarded(connection * const con, request_st * const r, co
* INADDR_ANY or in6addr_any, but must omit optional :port
* from con->srv_socket->srv_token for consistency */
if (semicolon) buffer_append_string_len(b, CONST_STR_LEN(";"));
if (semicolon) buffer_append_char(b, ';');
buffer_append_string_len(b, CONST_STR_LEN("by=\""));
#ifdef HAVE_SYS_UN_H
/* special-case: might need to encode unix domain socket path */
@ -716,7 +716,7 @@ static void proxy_set_Forwarded(connection * const con, request_st * const r, co
sock_addr_stringify_append_buffer(b, &addr);
}
}
buffer_append_string_len(b, CONST_STR_LEN("\""));
buffer_append_char(b, '"');
semicolon = 1;
}
@ -726,7 +726,7 @@ static void proxy_set_Forwarded(connection * const con, request_st * const r, co
: NULL;
/* expecting "http" or "https"
* (not checking if quoted-string and encoding needed) */
if (semicolon) buffer_append_string_len(b, CONST_STR_LEN(";"));
if (semicolon) buffer_append_char(b, ';');
if (NULL != eproto) {
buffer_append_str2(b, CONST_STR_LEN("proto="), BUF_PTR_LEN(eproto));
} else if (con->srv_socket->is_ssl) {
@ -743,19 +743,19 @@ static void proxy_set_Forwarded(connection * const con, request_st * const r, co
: NULL;
if (NULL != ehost) {
if (semicolon)
buffer_append_string_len(b, CONST_STR_LEN(";"));
buffer_append_char(b, ';');
buffer_append_string_len(b, CONST_STR_LEN("host=\""));
buffer_append_string_backslash_escaped(
b, BUF_PTR_LEN(ehost));
buffer_append_string_len(b, CONST_STR_LEN("\""));
buffer_append_char(b, '"');
semicolon = 1;
} else if (r->http_host && !buffer_is_blank(r->http_host)) {
if (semicolon)
buffer_append_string_len(b, CONST_STR_LEN(";"));
buffer_append_char(b, ';');
buffer_append_string_len(b, CONST_STR_LEN("host=\""));
buffer_append_string_backslash_escaped(
b, BUF_PTR_LEN(r->http_host));
buffer_append_string_len(b, CONST_STR_LEN("\""));
buffer_append_char(b, '"');
semicolon = 1;
}
}
@ -765,11 +765,11 @@ static void proxy_set_Forwarded(connection * const con, request_st * const r, co
http_header_env_get(r, CONST_STR_LEN("REMOTE_USER"));
if (NULL != remote_user) {
if (semicolon)
buffer_append_string_len(b, CONST_STR_LEN(";"));
buffer_append_char(b, ';');
buffer_append_string_len(b, CONST_STR_LEN("remote_user=\""));
buffer_append_string_backslash_escaped(
b, BUF_PTR_LEN(remote_user));
buffer_append_string_len(b, CONST_STR_LEN("\""));
buffer_append_char(b, '"');
/*semicolon = 1;*/
}
}

@ -335,11 +335,11 @@ static int mod_rrd_write_data(server *srv, plugin_data *p, rrd_config *s) {
BUF_PTR_LEN(s->path_rrd),
CONST_STR_LEN(" N:"));
buffer_append_int(cmd, s->bytes_read);
buffer_append_string_len(cmd, CONST_STR_LEN(":"));
buffer_append_char(cmd, ':');
buffer_append_int(cmd, s->bytes_written);
buffer_append_string_len(cmd, CONST_STR_LEN(":"));
buffer_append_char(cmd, ':');
buffer_append_int(cmd, s->requests);
buffer_append_string_len(cmd, CONST_STR_LEN("\n"));
buffer_append_char(cmd, '\n');
if (-1 == safe_write(p->write_fd, BUF_PTR_LEN(cmd))) {
log_error(srv->errh, __FILE__, __LINE__, "rrdtool-write: failed");

@ -209,11 +209,11 @@ static handler_t scgi_create_env(handler_ctx *hctx) {
scgi_env_add(b, CONST_STR_LEN("SCGI"), CONST_STR_LEN("1"));
buffer_clear(tb);
buffer_append_int(tb, buffer_clen(b)-10);
buffer_append_string_len(tb, CONST_STR_LEN(":"));
buffer_append_char(tb, ':');
len = buffer_clen(tb);
offset = 10 - len;
memcpy(b->ptr+offset, tb->ptr, len);
buffer_append_string_len(b, CONST_STR_LEN(","));
buffer_append_char(b, ',');
} else { /* LI_PROTOCOL_UWSGI */
/* http://uwsgi-docs.readthedocs.io/en/latest/Protocol.html */
size_t len = buffer_clen(b)-10;

@ -1120,14 +1120,14 @@ static int process_ssi_stmt(request_st * const r, handler_ctx * const p, const c
buffer_append_str2(tb, BUF_PTR_LEN(&ds->key), CONST_STR_LEN("="));
buffer_append_string_encoded(tb, BUF_PTR_LEN(&ds->value), ENCODING_MINIMAL_XML);
buffer_append_string_len(tb, CONST_STR_LEN("\n"));
buffer_append_char(tb, '\n');
}
for (i = 0; i < p->ssi_cgi_env->used; i++) {
data_string *ds = (data_string *)p->ssi_cgi_env->sorted[i];
buffer_append_str2(tb, BUF_PTR_LEN(&ds->key), CONST_STR_LEN("="));
buffer_append_string_encoded(tb, BUF_PTR_LEN(&ds->value), ENCODING_MINIMAL_XML);
buffer_append_string_len(tb, CONST_STR_LEN("\n"));
buffer_append_char(tb, '\n');
}
chunkqueue_append_mem(cq, BUF_PTR_LEN(tb));
break;

@ -177,7 +177,7 @@ static void mod_status_html_rtable_r (buffer * const b, const request_st * const
if (r->reqbody_length) {
buffer_append_int(b, r->reqbody_queue.bytes_in);
buffer_append_string_len(b, CONST_STR_LEN("/"));
buffer_append_char(b, '/');
buffer_append_int(b, r->reqbody_length);
}
else
@ -186,7 +186,7 @@ static void mod_status_html_rtable_r (buffer * const b, const request_st * const
buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"int\">"));
buffer_append_int(b, r->write_queue.bytes_out);
buffer_append_string_len(b, CONST_STR_LEN("/"));
buffer_append_char(b, '/');
buffer_append_int(b, r->write_queue.bytes_in);
buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">"));
@ -213,14 +213,14 @@ static void mod_status_html_rtable_r (buffer * const b, const request_st * const
buffer_append_string_encoded(b, BUF_PTR_LEN(&r->uri.path), ENCODING_HTML);
if (!buffer_is_blank(&r->uri.query)) {
buffer_append_string_len(b, CONST_STR_LEN("?"));
buffer_append_char(b, '?');
buffer_append_string_encoded(b, BUF_PTR_LEN(&r->uri.query), ENCODING_HTML);
}
if (!buffer_is_blank(&r->target_orig)) {
buffer_append_string_len(b, CONST_STR_LEN(" ("));
buffer_append_string_encoded(b, BUF_PTR_LEN(&r->target_orig), ENCODING_HTML);
buffer_append_string_len(b, CONST_STR_LEN(")"));
buffer_append_char(b, ')');
}
buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">"));
@ -391,7 +391,7 @@ static handler_t mod_status_handle_server_status_html(server *srv, request_st *
if (!buffer_is_blank(r->server_name) && r->server_name != &r->uri.authority) {
buffer_append_string_len(b, CONST_STR_LEN(" ("));
buffer_append_string_encoded(b, BUF_PTR_LEN(r->server_name), ENCODING_HTML);
buffer_append_string_len(b, CONST_STR_LEN(")"));
buffer_append_char(b, ')');
}
buffer_append_string_len(b, CONST_STR_LEN("</td></tr>\n"
"<tr><td>Uptime</td><td class=\"string\">"));
@ -665,7 +665,7 @@ static handler_t mod_status_handle_server_statistics(request_st * const r) {
buffer_append_str2(b, BUF_PTR_LEN(&st->sorted[i]->key),
CONST_STR_LEN(": "));
buffer_append_int(b, ((data_integer *)st->sorted[i])->value);
buffer_append_string_len(b, CONST_STR_LEN("\n"));
buffer_append_char(b, '\n');
}
chunkqueue_append_buffer_commit(&r->write_queue);

@ -74,7 +74,7 @@ static void mod_vhostdb_dbconf_add_scheme (server *srv, buffer *host)
while (*e!=' '&&*e!='\t'&&*e!='\r'&&*e!='\n'&&*e!=','&&*e!='\0')
++e;
if (!buffer_is_blank(tb))
buffer_append_string_len(tb, CONST_STR_LEN(","));
buffer_append_char(tb, ',');
for (j = 0; j < sizeof(schemes)/sizeof(char *); ++j) {
if (buffer_eq_icase_ssn(b, schemes[j], strlen(schemes[j]))) {
break;

@ -2515,8 +2515,8 @@ webdav_delete_dir (const plugin_config * const pconf,
#endif
if (s_isdir) {
buffer_append_string_len(&dst->path, CONST_STR_LEN("/"));
buffer_append_string_len(&dst->rel_path, CONST_STR_LEN("/"));
buffer_append_char(&dst->path, '/');
buffer_append_char(&dst->rel_path, '/');
multi_status |= webdav_delete_dir(pconf, dst, r, flags);
}
else {
@ -2570,9 +2570,9 @@ webdav_linktmp_rename (const plugin_config * const pconf,
buffer_append_str2(tmpb, BUF_PTR_LEN(dst),
CONST_STR_LEN("."));
buffer_append_int(tmpb, (long)getpid());
buffer_append_string_len(tmpb, CONST_STR_LEN("."));
buffer_append_char(tmpb, '.');
buffer_append_uint_hex_lc(tmpb, (uintptr_t)pconf); /*(stack/heap addr)*/
buffer_append_string_len(tmpb, CONST_STR_LEN("~"));
buffer_append_char(tmpb, '~');
if (buffer_clen(tmpb) < PATH_MAX
&& 0 == linkat(AT_FDCWD, src->ptr, AT_FDCWD, tmpb->ptr, 0)) {
@ -2637,9 +2637,9 @@ webdav_copytmp_rename (const plugin_config * const pconf,
buffer_append_str2(tmpb, BUF_PTR_LEN(&dst->path),
CONST_STR_LEN("."));
buffer_append_int(tmpb, (long)getpid());
buffer_append_string_len(tmpb, CONST_STR_LEN("."));
buffer_append_char(tmpb, '.');
buffer_append_uint_hex_lc(tmpb, (uintptr_t)pconf); /*(stack/heap addr)*/
buffer_append_string_len(tmpb, CONST_STR_LEN("~"));
buffer_append_char(tmpb, '~');
if (buffer_clen(tmpb) >= PATH_MAX)
return 414; /* URI Too Long */
@ -3218,10 +3218,10 @@ webdav_copymove_dir (const plugin_config * const pconf,
#endif
if (S_ISDIR(d_type)) { /* recursive call; depth first */
buffer_append_string_len(&src->path, CONST_STR_LEN("/"));
buffer_append_string_len(&dst->path, CONST_STR_LEN("/"));
buffer_append_string_len(&src->rel_path, CONST_STR_LEN("/"));
buffer_append_string_len(&dst->rel_path, CONST_STR_LEN("/"));
buffer_append_char(&src->path, '/');
buffer_append_char(&dst->path, '/');
buffer_append_char(&src->rel_path, '/');
buffer_append_char(&dst->rel_path, '/');
status = webdav_copymove_dir(pconf, src, dst, r, flags);
if (0 != status)
multi_status = 1;
@ -3743,8 +3743,8 @@ webdav_propfind_dir (webdav_propfind_bufs * const restrict pb)
}
#endif
if (S_ISDIR(pb->st.st_mode)) {
buffer_append_string_len(&dst->path, CONST_STR_LEN("/"));
buffer_append_string_len(&dst->rel_path, CONST_STR_LEN("/"));
buffer_append_char(&dst->path, '/');
buffer_append_char(&dst->rel_path, '/');
}
if (S_ISDIR(pb->st.st_mode) && -1 == pb->depth)
@ -4206,8 +4206,8 @@ mod_webdav_propfind (request_st * const r, const plugin_config * const pconf)
/* set "Content-Location" instead of sending 308 redirect to dir */
if (!http_response_redirect_to_directory(r, 0))
return HANDLER_FINISHED;
buffer_append_string_len(&r->physical.path, CONST_STR_LEN("/"));
buffer_append_string_len(&r->physical.rel_path,CONST_STR_LEN("/"));
buffer_append_char(&r->physical.path, '/');
buffer_append_char(&r->physical.rel_path, '/');
}
}
else if (buffer_has_pathsep_suffix(&r->physical.path)) {
@ -4412,12 +4412,12 @@ mod_webdav_delete (request_st * const r, const plugin_config * const pconf)
* and r->physical.rel_path, set Content-Location in
* response headers, and continue to serve the request */
#else
buffer_append_string_len(&r->physical.path, CONST_STR_LEN("/"));
buffer_append_string_len(&r->physical.rel_path,CONST_STR_LEN("/"));
buffer_append_char(&r->physical.path, '/');
buffer_append_char(&r->physical.rel_path, '/');
#if 0 /*(Content-Location not very useful to client after DELETE)*/
/*(? should it be target or target_orig ?)*/
/*(should be url-encoded path)*/
buffer_append_string_len(&r->target, CONST_STR_LEN("/"));
buffer_append_char(&r->target, '/');
http_header_response_set(r, HTTP_HEADER_CONTENT_LOCATION,
CONST_STR_LEN("Content-Location"),
BUF_PTR_LEN(&r->target));
@ -4916,12 +4916,12 @@ mod_webdav_put (request_st * const r, const plugin_config * const pconf)
buffer_append_str2(tmpb, BUF_PTR_LEN(&r->physical.path),
CONST_STR_LEN("."));
buffer_append_int(tmpb, (long)getpid());
buffer_append_string_len(tmpb, CONST_STR_LEN("."));
buffer_append_char(tmpb, '.');
if (c->type == MEM_CHUNK)
buffer_append_uint_hex_lc(tmpb, (uintptr_t)pconf); /*(stack/heap addr)*/
else
buffer_append_int(tmpb, (long)c->file.fd);
buffer_append_string_len(tmpb, CONST_STR_LEN("~"));
buffer_append_char(tmpb, '~');
if (buffer_clen(tmpb) >= PATH_MAX) { /*(temp file path too long)*/
http_status_set_error(r, 500); /* Internal Server Error */
@ -5425,8 +5425,8 @@ mod_webdav_proppatch (request_st * const r, const plugin_config * const pconf)
/* set "Content-Location" instead of sending 308 redirect to dir */
if (!http_response_redirect_to_directory(r, 0))
return HANDLER_FINISHED;
buffer_append_string_len(&r->physical.path, CONST_STR_LEN("/"));
buffer_append_string_len(&r->physical.rel_path,CONST_STR_LEN("/"));
buffer_append_char(&r->physical.path, '/');
buffer_append_char(&r->physical.rel_path, '/');
}
}
else if (buffer_has_pathsep_suffix(&r->physical.path)) {

@ -849,7 +849,7 @@ int network_init(server *srv, int stdin_fd) {
buffer_copy_buffer(b, srv->srvconf.bindhost);
/*(skip adding port if unix socket path)*/
if (!b->ptr || (b->ptr[0] != '/' && b->ptr[0] != '\\')) {
buffer_append_string_len(b, CONST_STR_LEN(":"));
buffer_append_char(b, ':');
buffer_append_int(b, srv->srvconf.port);
}
#ifdef __COVERITY__

@ -292,7 +292,7 @@ int http_request_host_normalize(buffer * const b, const int scheme_port) {
} while (0);
if (0 != port && port != scheme_port) {
buffer_append_string_len(b, CONST_STR_LEN(":"));
buffer_append_char(b, ':');
buffer_append_int(b, (int)port);
}

@ -1564,7 +1564,7 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
buffer * const tb = srv->tmp_buf;
buffer_clear(tb);
buffer_append_int(tb, srv->pid);
buffer_append_string_len(tb, CONST_STR_LEN("\n"));
buffer_append_char(tb, '\n');
if (-1 == write_all(pid_fd, BUF_PTR_LEN(tb))) {
log_perror(srv->errh, __FILE__, __LINE__, "Couldn't write pid file");
close(pid_fd);

@ -331,12 +331,12 @@ int sock_addr_stringify_append_buffer(buffer * const restrict b, const sock_addr
switch (saddr->plain.sa_family) {
case AF_INET:
if (0 != sock_addr_inet_ntop_append_buffer(b, saddr)) return -1;
buffer_append_string_len(b, CONST_STR_LEN(":"));
buffer_append_char(b, ':');
buffer_append_int(b, ntohs(saddr->ipv4.sin_port));
return 0;
#ifdef HAVE_IPV6
case AF_INET6:
buffer_append_string_len(b, CONST_STR_LEN("["));
buffer_append_char(b, '[');
if (0 != sock_addr_inet_ntop_append_buffer(b, saddr)) {
#ifdef __COVERITY__
force_assert(buffer_clen(b) > 0); /*(appended "[")*/
@ -411,9 +411,9 @@ int sock_addr_nameinfo_append_buffer(buffer * const restrict b, const sock_addr
"NOTICE: getnameinfo failed; using ip-address instead: %s",
gai_strerror(rc));
buffer_append_string_len(b, CONST_STR_LEN("["));
buffer_append_char(b, '[');
sock_addr_inet_ntop_append_buffer(b, saddr);
buffer_append_string_len(b, CONST_STR_LEN("]"));
buffer_append_char(b, ']');
} else {
buffer_append_string(b, hbuf);
}

Loading…
Cancel
Save