mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-12 20:58:01 +00:00
MEDIUM: chunks: make the chunk struct's fields match the buffer struct
Chunks are only a subset of a buffer (a non-wrapping version with no head offset). Despite this we still carry a lot of duplicated code between buffers and chunks. Replacing chunks with buffers would significantly reduce the maintenance efforts. This first patch renames the chunk's fields to match the name and types used by struct buffers, with the goal of isolating the code changes from the declaration changes. Most of the changes were made with spatch using this coccinelle script : @rule_d1@ typedef chunk; struct chunk chunk; @@ - chunk.str + chunk.area @rule_d2@ typedef chunk; struct chunk chunk; @@ - chunk.len + chunk.data @rule_i1@ typedef chunk; struct chunk *chunk; @@ - chunk->str + chunk->area @rule_i2@ typedef chunk; struct chunk *chunk; @@ - chunk->len + chunk->data Some minor updates to 3 http functions had to be performed to take size_t ints instead of ints in order to match the unsigned length here.
This commit is contained in:
parent
c9fa0480af
commit
843b7cbe9d
@ -29,8 +29,8 @@ uint8_t buf[MAX_RQ_SIZE];
|
||||
char trash_buf[MAX_RQ_SIZE];
|
||||
char tmp_buf[MAX_RQ_SIZE];
|
||||
|
||||
struct chunk trash = { .str = trash_buf, .len = 0, .size = sizeof(trash_buf) };
|
||||
struct chunk tmp = { .str = tmp_buf, .len = 0, .size = sizeof(tmp_buf) };
|
||||
struct chunk trash = { .area = trash_buf, .data = 0, .size = sizeof(trash_buf) };
|
||||
struct chunk tmp = { .area = tmp_buf, .data = 0, .size = sizeof(tmp_buf) };
|
||||
|
||||
/* displays a <len> long memory block at <buf>, assuming first byte of <buf>
|
||||
* has address <baseaddr>. String <pfx> may be placed as a prefix in front of
|
||||
@ -193,10 +193,11 @@ int main(int argc, char **argv)
|
||||
//printf("\e[1;35m%s\e[0m\n", istpad(trash.str, list[idx].v).ptr);
|
||||
|
||||
printf(" %s: ", list[idx].n.ptr ?
|
||||
istpad(trash.str, list[idx].n).ptr :
|
||||
istpad(trash.area, list[idx].n).ptr :
|
||||
h2_phdr_to_str(list[idx].n.len));
|
||||
|
||||
printf("%s [n=(%p,%d) v=(%p,%d)]\n", istpad(trash.str, list[idx].v).ptr,
|
||||
printf("%s [n=(%p,%d) v=(%p,%d)]\n",
|
||||
istpad(trash.area, list[idx].v).ptr,
|
||||
list[idx].n.ptr, (int)list[idx].n.len, list[idx].v.ptr, (int)list[idx].v.len);
|
||||
}
|
||||
puts(">>>");
|
||||
|
@ -83,8 +83,8 @@ static apr_status_t defender_bucket_read(apr_bucket *b, const char **str,
|
||||
{
|
||||
struct apr_bucket_defender *d = b->data;
|
||||
|
||||
*str = d->buf.str;
|
||||
*len = d->buf.len;
|
||||
*str = d->buf.area;
|
||||
*len = d->buf.data;
|
||||
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
@ -103,11 +103,11 @@ static apr_bucket *defender_bucket_make(apr_bucket *b, const struct chunk *buf)
|
||||
|
||||
d = apr_bucket_alloc(sizeof(*d), b->list);
|
||||
|
||||
d->buf.str = buf->str;
|
||||
d->buf.len = buf->len;
|
||||
d->buf.area = buf->area;
|
||||
d->buf.data = buf->data;
|
||||
d->buf.size = 0;
|
||||
|
||||
b = apr_bucket_shared_make(b, d, 0, buf->len);
|
||||
b = apr_bucket_shared_make(b, d, 0, buf->data);
|
||||
b->type = &apr_bucket_type_defender;
|
||||
return b;
|
||||
}
|
||||
@ -487,10 +487,10 @@ int defender_process_request(struct worker *worker, struct defender_request *req
|
||||
if (!(r->useragent_ip = defender_addr2str(r->pool, &request->clientip)))
|
||||
goto out;
|
||||
|
||||
if (request->id.data.u.str.str && request->id.data.u.str.len > 0) {
|
||||
if (request->id.data.u.str.area && request->id.data.u.str.data > 0) {
|
||||
apr_table_setn(r->subprocess_env, "UNIQUE_ID",
|
||||
defender_strdup(r->pool, request->id.data.u.str.str,
|
||||
request->id.data.u.str.len));
|
||||
defender_strdup(r->pool, request->id.data.u.str.area,
|
||||
request->id.data.u.str.data));
|
||||
}
|
||||
else {
|
||||
apr_table_setn(r->subprocess_env, "UNIQUE_ID",
|
||||
@ -502,37 +502,37 @@ int defender_process_request(struct worker *worker, struct defender_request *req
|
||||
query = &request->query.data.u.str;
|
||||
version = &request->version.data.u.str;
|
||||
|
||||
r->method_number = lookup_builtin_method(method->str, method->len);
|
||||
if (!(r->method = defender_strdup(r->pool, method->str, method->len)))
|
||||
r->method_number = lookup_builtin_method(method->area, method->data);
|
||||
if (!(r->method = defender_strdup(r->pool, method->area, method->data)))
|
||||
goto out;
|
||||
|
||||
r->unparsed_uri = defender_printf(r->pool, "%.*s%s%.*s",
|
||||
path->len, path->str,
|
||||
query->len > 0 ? "?" : "",
|
||||
query->len, query->str);
|
||||
path->data, path->area,
|
||||
query->data > 0 ? "?" : "",
|
||||
query->data, query->area);
|
||||
if (!r->unparsed_uri)
|
||||
goto out;
|
||||
|
||||
if (!(r->uri = defender_strdup(r->pool, path->str, path->len)))
|
||||
if (!(r->uri = defender_strdup(r->pool, path->area, path->data)))
|
||||
goto out;
|
||||
|
||||
r->parsed_uri.path = r->filename = r->uri;
|
||||
|
||||
if (!(r->args = defender_strdup(r->pool, query->str, query->len)))
|
||||
if (!(r->args = defender_strdup(r->pool, query->area, query->data)))
|
||||
goto out;
|
||||
|
||||
r->parsed_uri.query = r->args;
|
||||
|
||||
r->protocol = defender_printf(r->pool, "%s%.*s",
|
||||
version->len > 0 ? "HTTP/" : "",
|
||||
version->len, version->str);
|
||||
version->data > 0 ? "HTTP/" : "",
|
||||
version->data, version->area);
|
||||
if (!r->protocol)
|
||||
goto out;
|
||||
|
||||
r->the_request = defender_printf(r->pool, "%.*s %s%s%s",
|
||||
method->len, method->str,
|
||||
method->data, method->area,
|
||||
r->unparsed_uri,
|
||||
version->len > 0 ? " " : "",
|
||||
version->data > 0 ? " " : "",
|
||||
r->protocol);
|
||||
if (!r->the_request)
|
||||
goto out;
|
||||
@ -541,8 +541,8 @@ int defender_process_request(struct worker *worker, struct defender_request *req
|
||||
if (request->headers.data.type != SMP_T_BIN)
|
||||
goto misc;
|
||||
|
||||
hdr_ptr = request->headers.data.u.str.str;
|
||||
hdr_end = hdr_ptr + request->headers.data.u.str.len;
|
||||
hdr_ptr = request->headers.data.u.str.area;
|
||||
hdr_end = hdr_ptr + request->headers.data.u.str.data;
|
||||
|
||||
while (1) {
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
|
@ -218,28 +218,28 @@ int modsecurity_process(struct worker *worker, struct modsecurity_parameters *pa
|
||||
int return_code = -1;
|
||||
|
||||
/* Decode uniqueid. */
|
||||
uniqueid = params->uniqueid.data.u.str.str;
|
||||
uniqueid_len = params->uniqueid.data.u.str.len;
|
||||
uniqueid = params->uniqueid.data.u.str.area;
|
||||
uniqueid_len = params->uniqueid.data.u.str.data;
|
||||
|
||||
/* Decode method. */
|
||||
meth = params->method.data.u.str.str;
|
||||
meth_len = params->method.data.u.str.len;
|
||||
meth = params->method.data.u.str.area;
|
||||
meth_len = params->method.data.u.str.data;
|
||||
|
||||
/* Decode path. */
|
||||
path = params->path.data.u.str.str;
|
||||
path_len = params->path.data.u.str.len;
|
||||
path = params->path.data.u.str.area;
|
||||
path_len = params->path.data.u.str.data;
|
||||
|
||||
/* Decode query string. */
|
||||
qs = params->query.data.u.str.str;
|
||||
qs_len = params->query.data.u.str.len;
|
||||
qs = params->query.data.u.str.area;
|
||||
qs_len = params->query.data.u.str.data;
|
||||
|
||||
/* Decode version. */
|
||||
vers = params->vers.data.u.str.str;
|
||||
vers_len = params->vers.data.u.str.len;
|
||||
vers = params->vers.data.u.str.area;
|
||||
vers_len = params->vers.data.u.str.data;
|
||||
|
||||
/* Decode header binary block. */
|
||||
buf = params->hdrs_bin.data.u.str.str;
|
||||
end = buf + params->hdrs_bin.data.u.str.len;
|
||||
buf = params->hdrs_bin.data.u.str.area;
|
||||
end = buf + params->hdrs_bin.data.u.str.data;
|
||||
|
||||
/* Decode each header. */
|
||||
hdr_nb = 0;
|
||||
@ -289,8 +289,8 @@ int modsecurity_process(struct worker *worker, struct modsecurity_parameters *pa
|
||||
return -1;
|
||||
|
||||
/* Decode body. */
|
||||
body = params->body.data.u.str.str;
|
||||
body_len = params->body.data.u.str.len;
|
||||
body = params->body.data.u.str.area;
|
||||
body_len = params->body.data.u.str.data;
|
||||
|
||||
fail = 1;
|
||||
|
||||
|
@ -31,9 +31,9 @@
|
||||
|
||||
/* describes a chunk of string */
|
||||
struct chunk {
|
||||
char *str; /* beginning of the string itself. Might not be 0-terminated */
|
||||
int size; /* total size of the buffer, 0 if the *str is read-only */
|
||||
int len; /* current size of the string from first to last char. <0 = uninit. */
|
||||
char *area; /* points to <size> bytes */
|
||||
size_t size; /* buffer size in bytes */
|
||||
size_t data; /* amount of data after head including wrapping */
|
||||
};
|
||||
|
||||
struct pool_head *pool_head_trash;
|
||||
@ -66,13 +66,13 @@ static inline void free_trash_chunk(struct chunk *chunk)
|
||||
|
||||
static inline void chunk_reset(struct chunk *chk)
|
||||
{
|
||||
chk->len = 0;
|
||||
chk->data = 0;
|
||||
}
|
||||
|
||||
static inline void chunk_init(struct chunk *chk, char *str, size_t size)
|
||||
{
|
||||
chk->str = str;
|
||||
chk->len = 0;
|
||||
chk->area = str;
|
||||
chk->data = 0;
|
||||
chk->size = size;
|
||||
}
|
||||
|
||||
@ -83,8 +83,8 @@ static inline int chunk_initlen(struct chunk *chk, char *str, size_t size, int l
|
||||
if (len < 0 || (size && len > size))
|
||||
return 0;
|
||||
|
||||
chk->str = str;
|
||||
chk->len = len;
|
||||
chk->area = str;
|
||||
chk->data = len;
|
||||
chk->size = size;
|
||||
|
||||
return 1;
|
||||
@ -93,8 +93,8 @@ static inline int chunk_initlen(struct chunk *chk, char *str, size_t size, int l
|
||||
/* this is only for temporary manipulation, the chunk is read-only */
|
||||
static inline void chunk_initstr(struct chunk *chk, const char *str)
|
||||
{
|
||||
chk->str = (char *)str;
|
||||
chk->len = strlen(str);
|
||||
chk->area = (char *)str;
|
||||
chk->data = strlen(str);
|
||||
chk->size = 0; /* mark it read-only */
|
||||
}
|
||||
|
||||
@ -106,8 +106,8 @@ static inline int chunk_memcpy(struct chunk *chk, const char *src, size_t len)
|
||||
if (unlikely(len >= chk->size))
|
||||
return 0;
|
||||
|
||||
chk->len = len;
|
||||
memcpy(chk->str, src, len);
|
||||
chk->data = len;
|
||||
memcpy(chk->area, src, len);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -117,11 +117,11 @@ static inline int chunk_memcpy(struct chunk *chk, const char *src, size_t len)
|
||||
*/
|
||||
static inline int chunk_memcat(struct chunk *chk, const char *src, size_t len)
|
||||
{
|
||||
if (unlikely(chk->len < 0 || chk->len + len >= chk->size))
|
||||
if (unlikely(chk->data < 0 || chk->data + len >= chk->size))
|
||||
return 0;
|
||||
|
||||
memcpy(chk->str + chk->len, src, len);
|
||||
chk->len += len;
|
||||
memcpy(chk->area + chk->data, src, len);
|
||||
chk->data += len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -137,8 +137,8 @@ static inline int chunk_strcpy(struct chunk *chk, const char *str)
|
||||
if (unlikely(len >= chk->size))
|
||||
return 0;
|
||||
|
||||
chk->len = len;
|
||||
memcpy(chk->str, str, len + 1);
|
||||
chk->data = len;
|
||||
memcpy(chk->area, str, len + 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -152,11 +152,11 @@ static inline int chunk_strcat(struct chunk *chk, const char *str)
|
||||
|
||||
len = strlen(str);
|
||||
|
||||
if (unlikely(chk->len < 0 || chk->len + len >= chk->size))
|
||||
if (unlikely(chk->data < 0 || chk->data + len >= chk->size))
|
||||
return 0;
|
||||
|
||||
memcpy(chk->str + chk->len, str, len + 1);
|
||||
chk->len += len;
|
||||
memcpy(chk->area + chk->data, str, len + 1);
|
||||
chk->data += len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -165,11 +165,11 @@ static inline int chunk_strcat(struct chunk *chk, const char *str)
|
||||
*/
|
||||
static inline int chunk_strncat(struct chunk *chk, const char *str, int nb)
|
||||
{
|
||||
if (unlikely(chk->len < 0 || chk->len + nb >= chk->size))
|
||||
if (unlikely(chk->data < 0 || chk->data + nb >= chk->size))
|
||||
return 0;
|
||||
|
||||
memcpy(chk->str + chk->len, str, nb);
|
||||
chk->len += nb;
|
||||
memcpy(chk->area + chk->data, str, nb);
|
||||
chk->data += nb;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -187,17 +187,17 @@ static inline int chunk_strncat(struct chunk *chk, const char *str, int nb)
|
||||
*/
|
||||
static inline char *chunk_newstr(struct chunk *chk)
|
||||
{
|
||||
if (chk->len < 0 || chk->len + 1 >= chk->size)
|
||||
if (chk->data < 0 || chk->data + 1 >= chk->size)
|
||||
return NULL;
|
||||
|
||||
chk->str[chk->len++] = 0;
|
||||
return chk->str + chk->len;
|
||||
chk->area[chk->data++] = 0;
|
||||
return chk->area + chk->data;
|
||||
}
|
||||
|
||||
static inline void chunk_drop(struct chunk *chk)
|
||||
{
|
||||
chk->str = NULL;
|
||||
chk->len = -1;
|
||||
chk->area = NULL;
|
||||
chk->data = -1;
|
||||
chk->size = 0;
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ static inline void chunk_destroy(struct chunk *chk)
|
||||
if (!chk->size)
|
||||
return;
|
||||
|
||||
free(chk->str);
|
||||
free(chk->area);
|
||||
chunk_drop(chk);
|
||||
}
|
||||
|
||||
@ -219,28 +219,28 @@ static inline void chunk_destroy(struct chunk *chk)
|
||||
*/
|
||||
static inline char *chunk_dup(struct chunk *dst, const struct chunk *src)
|
||||
{
|
||||
if (!dst || !src || src->len < 0 || !src->str)
|
||||
if (!dst || !src || src->data < 0 || !src->area)
|
||||
return NULL;
|
||||
|
||||
if (dst->size)
|
||||
free(dst->str);
|
||||
dst->len = src->len;
|
||||
dst->size = src->len;
|
||||
free(dst->area);
|
||||
dst->data = src->data;
|
||||
dst->size = src->data;
|
||||
if (dst->size < src->size || !src->size)
|
||||
dst->size++;
|
||||
|
||||
dst->str = (char *)malloc(dst->size);
|
||||
if (!dst->str) {
|
||||
dst->len = 0;
|
||||
dst->area = (char *)malloc(dst->size);
|
||||
if (!dst->area) {
|
||||
dst->data = 0;
|
||||
dst->size = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(dst->str, src->str, dst->len);
|
||||
if (dst->len < dst->size)
|
||||
dst->str[dst->len] = 0;
|
||||
memcpy(dst->area, src->area, dst->data);
|
||||
if (dst->data < dst->size)
|
||||
dst->area[dst->data] = 0;
|
||||
|
||||
return dst->str;
|
||||
return dst->area;
|
||||
}
|
||||
|
||||
#endif /* _TYPES_CHUNK_H */
|
||||
|
@ -52,7 +52,7 @@ static inline void action_build_list(struct list *keywords, struct chunk *chk)
|
||||
char *end;
|
||||
int l;
|
||||
|
||||
p = chk->str;
|
||||
p = chk->area;
|
||||
end = p + chk->size - 1;
|
||||
list_for_each_entry(kw_list, keywords, list) {
|
||||
for (i = 0; kw_list->kw[i].kw != NULL; i++) {
|
||||
@ -62,7 +62,7 @@ static inline void action_build_list(struct list *keywords, struct chunk *chk)
|
||||
p += l;
|
||||
}
|
||||
}
|
||||
if (p > chk->str)
|
||||
if (p > chk->area)
|
||||
*(p-2) = '\0';
|
||||
else
|
||||
*p = '\0';
|
||||
|
@ -788,9 +788,9 @@ static inline int ci_putchk(struct channel *chn, struct chunk *chunk)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ci_putblk(chn, chunk->str, chunk->len);
|
||||
ret = ci_putblk(chn, chunk->area, chunk->data);
|
||||
if (ret > 0)
|
||||
chunk->len -= ret;
|
||||
chunk->data -= ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ int http_find_next_header(char *sol, struct hdr_idx *idx,
|
||||
struct hdr_ctx *ctx);
|
||||
char *find_hdr_value_end(char *s, const char *e);
|
||||
char *extract_cookie_value(char *hdr, const char *hdr_end, char *cookie_name,
|
||||
size_t cookie_name_l, int list, char **value, int *value_l);
|
||||
size_t cookie_name_l, int list, char **value, size_t *value_l);
|
||||
int http_header_match2(const char *hdr, const char *end, const char *name, int len);
|
||||
int http_remove_header2(struct http_msg *msg, struct hdr_idx *idx, struct hdr_ctx *ctx);
|
||||
int http_header_add_tail2(struct http_msg *msg, struct hdr_idx *hdr_idx, const char *text, int len);
|
||||
@ -104,7 +104,7 @@ void http_capture_bad_message(struct proxy *proxy, struct error_snapshot *es, st
|
||||
enum h1_state state, struct proxy *other_end);
|
||||
unsigned int http_get_hdr(const struct http_msg *msg, const char *hname, int hlen,
|
||||
struct hdr_idx *idx, int occ,
|
||||
struct hdr_ctx *ctx, char **vptr, int *vlen);
|
||||
struct hdr_ctx *ctx, char **vptr, size_t *vlen);
|
||||
char *http_get_path(struct http_txn *txn);
|
||||
const char *get_reason(unsigned int status);
|
||||
|
||||
|
@ -92,22 +92,22 @@ int smp_is_safe(struct sample *smp)
|
||||
/* Fall through */
|
||||
|
||||
case SMP_T_STR:
|
||||
if ((smp->data.u.str.len < 0) ||
|
||||
(smp->data.u.str.size && smp->data.u.str.len >= smp->data.u.str.size))
|
||||
if ((smp->data.u.str.data < 0) ||
|
||||
(smp->data.u.str.size && smp->data.u.str.data >= smp->data.u.str.size))
|
||||
return 0;
|
||||
|
||||
if (smp->data.u.str.str[smp->data.u.str.len] == 0)
|
||||
if (smp->data.u.str.area[smp->data.u.str.data] == 0)
|
||||
return 1;
|
||||
|
||||
if (!smp->data.u.str.size || (smp->flags & SMP_F_CONST))
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str[smp->data.u.str.len] = 0;
|
||||
smp->data.u.str.area[smp->data.u.str.data] = 0;
|
||||
return 1;
|
||||
|
||||
case SMP_T_BIN:
|
||||
return (smp->data.u.str.len >= 0) &&
|
||||
(!smp->data.u.str.size || smp->data.u.str.len <= smp->data.u.str.size);
|
||||
return (smp->data.u.str.data >= 0) &&
|
||||
(!smp->data.u.str.size || smp->data.u.str.data <= smp->data.u.str.size);
|
||||
|
||||
default:
|
||||
return 1;
|
||||
@ -145,18 +145,18 @@ int smp_is_rw(struct sample *smp)
|
||||
|
||||
case SMP_T_STR:
|
||||
if (!smp->data.u.str.size ||
|
||||
smp->data.u.str.len < 0 ||
|
||||
smp->data.u.str.len >= smp->data.u.str.size)
|
||||
smp->data.u.str.data < 0 ||
|
||||
smp->data.u.str.data >= smp->data.u.str.size)
|
||||
return 0;
|
||||
|
||||
if (smp->data.u.str.str[smp->data.u.str.len] != 0)
|
||||
smp->data.u.str.str[smp->data.u.str.len] = 0;
|
||||
if (smp->data.u.str.area[smp->data.u.str.data] != 0)
|
||||
smp->data.u.str.area[smp->data.u.str.data] = 0;
|
||||
return 1;
|
||||
|
||||
case SMP_T_BIN:
|
||||
return smp->data.u.str.size &&
|
||||
smp->data.u.str.len >= 0 &&
|
||||
smp->data.u.str.len <= smp->data.u.str.size;
|
||||
smp->data.u.str.data >= 0 &&
|
||||
smp->data.u.str.data <= smp->data.u.str.size;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
|
@ -180,18 +180,20 @@ spoe_encode_data(struct sample *smp, unsigned int *off, char **buf, char *end)
|
||||
*p++ = (smp->data.type == SMP_T_STR)
|
||||
? SPOE_DATA_T_STR
|
||||
: SPOE_DATA_T_BIN;
|
||||
ret = spoe_encode_frag_buffer(chk->str, chk->len, &p, end);
|
||||
ret = spoe_encode_frag_buffer(chk->area,
|
||||
chk->data, &p,
|
||||
end);
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
/* The sample has been fragmented, encode remaining data */
|
||||
ret = MIN(chk->len - *off, end - p);
|
||||
memcpy(p, chk->str + *off, ret);
|
||||
ret = MIN(chk->data - *off, end - p);
|
||||
memcpy(p, chk->area + *off, ret);
|
||||
p += ret;
|
||||
}
|
||||
/* Now update <*off> */
|
||||
if (ret + *off != chk->len)
|
||||
if (ret + *off != chk->data)
|
||||
*off += ret;
|
||||
else
|
||||
*off = 0;
|
||||
@ -214,8 +216,8 @@ spoe_encode_data(struct sample *smp, unsigned int *off, char **buf, char *end)
|
||||
case HTTP_METH_CONNECT: m = "CONNECT"; len = 7; break;
|
||||
|
||||
default :
|
||||
m = smp->data.u.meth.str.str;
|
||||
len = smp->data.u.meth.str.len;
|
||||
m = smp->data.u.meth.str.area;
|
||||
len = smp->data.u.meth.str.data;
|
||||
}
|
||||
if (spoe_encode_buffer(m, len, &p, end) == -1)
|
||||
return -1;
|
||||
@ -333,8 +335,8 @@ spoe_decode_data(char **buf, char *end, struct sample *smp)
|
||||
/* All the buffer must be decoded */
|
||||
if (spoe_decode_buffer(&p, end, &str, &sz) == -1)
|
||||
return -1;
|
||||
smp->data.u.str.str = str;
|
||||
smp->data.u.str.len = sz;
|
||||
smp->data.u.str.area = str;
|
||||
smp->data.u.str.data = sz;
|
||||
smp->data.type = (type == SPOE_DATA_T_STR) ? SMP_T_STR : SMP_T_BIN;
|
||||
break;
|
||||
}
|
||||
|
78
src/51d.c
78
src/51d.c
@ -160,7 +160,7 @@ static void _51d_lru_free(void *cache_entry)
|
||||
if (!ptr)
|
||||
return;
|
||||
|
||||
free(ptr->str);
|
||||
free(ptr->area);
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
@ -189,15 +189,15 @@ static void _51d_insert_cache_entry(struct sample *smp, struct lru64 *lru, void*
|
||||
if (!cache_entry)
|
||||
return;
|
||||
|
||||
cache_entry->str = _51d_malloc(smp->data.u.str.len + 1);
|
||||
if (!cache_entry->str) {
|
||||
cache_entry->area = _51d_malloc(smp->data.u.str.data + 1);
|
||||
if (!cache_entry->area) {
|
||||
free(cache_entry);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(cache_entry->str, smp->data.u.str.str, smp->data.u.str.len);
|
||||
cache_entry->str[smp->data.u.str.len] = 0;
|
||||
cache_entry->len = smp->data.u.str.len;
|
||||
memcpy(cache_entry->area, smp->data.u.str.area, smp->data.u.str.data);
|
||||
cache_entry->area[smp->data.u.str.data] = 0;
|
||||
cache_entry->data = smp->data.u.str.data;
|
||||
lru64_commit(lru, cache_entry, domain, 0, _51d_lru_free);
|
||||
}
|
||||
|
||||
@ -206,8 +206,8 @@ static void _51d_insert_cache_entry(struct sample *smp, struct lru64 *lru, void*
|
||||
static void _51d_retrieve_cache_entry(struct sample *smp, struct lru64 *lru)
|
||||
{
|
||||
struct chunk *cache_entry = lru->data;
|
||||
smp->data.u.str.str = cache_entry->str;
|
||||
smp->data.u.str.len = cache_entry->len;
|
||||
smp->data.u.str.area = cache_entry->area;
|
||||
smp->data.u.str.data = cache_entry->data;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -228,10 +228,9 @@ static void _51d_set_headers(struct sample *smp, fiftyoneDegreesWorkset *ws)
|
||||
|
||||
for (i = 0; i < global_51degrees.header_count; i++) {
|
||||
ctx.idx = 0;
|
||||
if (http_find_full_header2(
|
||||
(global_51degrees.header_names + i)->str,
|
||||
(global_51degrees.header_names + i)->len,
|
||||
msg->chn->buf->p, idx, &ctx) == 1) {
|
||||
if (http_find_full_header2((global_51degrees.header_names + i)->area,
|
||||
(global_51degrees.header_names + i)->data,
|
||||
msg->chn->buf->p, idx, &ctx) == 1) {
|
||||
ws->importantHeaders[ws->importantHeadersCount].header = ws->dataSet->httpHeaders + i;
|
||||
ws->importantHeaders[ws->importantHeadersCount].headerValue = ctx.line + ctx.val;
|
||||
ws->importantHeaders[ws->importantHeadersCount].headerValueLength = ctx.vlen;
|
||||
@ -256,10 +255,9 @@ static void _51d_set_device_offsets(struct sample *smp)
|
||||
|
||||
for (index = 0; index < global_51degrees.header_count; index++) {
|
||||
ctx.idx = 0;
|
||||
if (http_find_full_header2(
|
||||
(global_51degrees.header_names + index)->str,
|
||||
(global_51degrees.header_names + index)->len,
|
||||
msg->chn->buf->p, idx, &ctx) == 1) {
|
||||
if (http_find_full_header2((global_51degrees.header_names + index)->area,
|
||||
(global_51degrees.header_names + index)->data,
|
||||
msg->chn->buf->p, idx, &ctx) == 1) {
|
||||
(offsets->firstOffset + offsets->size)->httpHeaderOffset = *(global_51degrees.header_offsets + index);
|
||||
(offsets->firstOffset + offsets->size)->deviceOffset = fiftyoneDegreesGetDeviceOffset(&global_51degrees.data_set, ctx.line + ctx.val);
|
||||
offsets->size++;
|
||||
@ -307,11 +305,11 @@ static void _51d_process_match(const struct arg *args, struct sample *smp)
|
||||
const char* property_name;
|
||||
|
||||
/* Loop through property names passed to the filter and fetch them from the dataset. */
|
||||
while (args[i].data.str.str) {
|
||||
while (args[i].data.str.area) {
|
||||
/* Try to find request property in dataset. */
|
||||
found = 0;
|
||||
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
||||
if (strcmp("Method", args[i].data.str.str) == 0) {
|
||||
if (strcmp("Method", args[i].data.str.area) == 0) {
|
||||
switch(ws->method) {
|
||||
case EXACT: methodName = "Exact"; break;
|
||||
case NUMERIC: methodName = "Numeric"; break;
|
||||
@ -323,18 +321,18 @@ static void _51d_process_match(const struct arg *args, struct sample *smp)
|
||||
chunk_appendf(temp, "%s", methodName);
|
||||
found = 1;
|
||||
}
|
||||
else if (strcmp("Difference", args[i].data.str.str) == 0) {
|
||||
else if (strcmp("Difference", args[i].data.str.area) == 0) {
|
||||
chunk_appendf(temp, "%d", ws->difference);
|
||||
found = 1;
|
||||
}
|
||||
else if (strcmp("Rank", args[i].data.str.str) == 0) {
|
||||
else if (strcmp("Rank", args[i].data.str.area) == 0) {
|
||||
chunk_appendf(temp, "%d", fiftyoneDegreesGetSignatureRank(ws));
|
||||
found = 1;
|
||||
}
|
||||
else {
|
||||
for (j = 0; j < ws->dataSet->requiredPropertyCount; j++) {
|
||||
property_name = fiftyoneDegreesGetPropertyName(ws->dataSet, ws->dataSet->requiredProperties[j]);
|
||||
if (strcmp(property_name, args[i].data.str.str) == 0) {
|
||||
if (strcmp(property_name, args[i].data.str.area) == 0) {
|
||||
found = 1;
|
||||
fiftyoneDegreesSetValues(ws, j);
|
||||
chunk_appendf(temp, "%s", fiftyoneDegreesGetValueName(ws->dataSet, *ws->values));
|
||||
@ -347,7 +345,7 @@ static void _51d_process_match(const struct arg *args, struct sample *smp)
|
||||
found = 0;
|
||||
for (j = 0; j < requiredPropertiesCount; j++) {
|
||||
property_name = requiredProperties[j];
|
||||
if (strcmp(property_name, args[i].data.str.str) == 0 &&
|
||||
if (strcmp(property_name, args[i].data.str.area) == 0 &&
|
||||
fiftyoneDegreesGetValueFromOffsets(&global_51degrees.data_set, deviceOffsets, j, valuesBuffer, 1024) > 0) {
|
||||
found = 1;
|
||||
chunk_appendf(temp, "%s", valuesBuffer);
|
||||
@ -363,13 +361,13 @@ static void _51d_process_match(const struct arg *args, struct sample *smp)
|
||||
++i;
|
||||
}
|
||||
|
||||
if (temp->len) {
|
||||
--temp->len;
|
||||
temp->str[temp->len] = '\0';
|
||||
if (temp->data) {
|
||||
--temp->data;
|
||||
temp->area[temp->data] = '\0';
|
||||
}
|
||||
|
||||
smp->data.u.str.str = temp->str;
|
||||
smp->data.u.str.len = temp->len;
|
||||
smp->data.u.str.area = temp->area;
|
||||
smp->data.u.str.data = temp->data;
|
||||
}
|
||||
|
||||
static int _51d_fetch(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
@ -457,7 +455,7 @@ static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
|
||||
if (_51d_lru_tree) {
|
||||
unsigned long long seed = _51d_lru_seed ^ (long)args;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
_51d_lru_tree, (void*)args, 0);
|
||||
if (lru && lru->domain) {
|
||||
_51d_retrieve_cache_entry(smp, lru);
|
||||
@ -475,15 +473,16 @@ static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
|
||||
if (!smp_dup(smp))
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str[smp->data.u.str.len] = '\0';
|
||||
smp->data.u.str.area[smp->data.u.str.data] = '\0';
|
||||
|
||||
/* Perform detection. */
|
||||
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
||||
fiftyoneDegreesMatch(ws, smp->data.u.str.str);
|
||||
fiftyoneDegreesMatch(ws, smp->data.u.str.area);
|
||||
_51d_process_match(args, smp, ws);
|
||||
#endif
|
||||
#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
|
||||
global_51degrees.device_offsets.firstOffset->deviceOffset = fiftyoneDegreesGetDeviceOffset(&global_51degrees.data_set, smp->data.u.str.str);
|
||||
global_51degrees.device_offsets.firstOffset->deviceOffset = fiftyoneDegreesGetDeviceOffset(&global_51degrees.data_set,
|
||||
smp->data.u.str.area);
|
||||
global_51degrees.device_offsets.size = 1;
|
||||
_51d_process_match(args, smp);
|
||||
#endif
|
||||
@ -507,9 +506,9 @@ void _51d_init_http_headers()
|
||||
global_51degrees.header_names = malloc(global_51degrees.header_count * sizeof(struct chunk));
|
||||
for (index = 0; index < global_51degrees.header_count; index++) {
|
||||
headerName = fiftyoneDegreesGetString(ds, ds->httpHeaders[index].headerNameOffset);
|
||||
(global_51degrees.header_names + index)->str = (char*)&headerName->firstByte;
|
||||
(global_51degrees.header_names + index)->len = headerName->length - 1;
|
||||
(global_51degrees.header_names + index)->size = (global_51degrees.header_names + index)->len;
|
||||
(global_51degrees.header_names + index)->area = (char*)&headerName->firstByte;
|
||||
(global_51degrees.header_names + index)->data = headerName->length - 1;
|
||||
(global_51degrees.header_names + index)->size = (global_51degrees.header_names + index)->data;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -526,9 +525,9 @@ void _51d_init_http_headers()
|
||||
global_51degrees.header_offsets = malloc(global_51degrees.header_count * sizeof(int32_t));
|
||||
for (index = 0; index < global_51degrees.header_count; index++) {
|
||||
global_51degrees.header_offsets[index] = fiftyoneDegreesGetHttpHeaderNameOffset(ds, index);
|
||||
global_51degrees.header_names[index].str = (char*)fiftyoneDegreesGetHttpHeaderNamePointer(ds, index);
|
||||
global_51degrees.header_names[index].len = strlen(global_51degrees.header_names[index].str);
|
||||
global_51degrees.header_names[index].size = global_51degrees.header_names[index].len;
|
||||
global_51degrees.header_names->area = (char*)fiftyoneDegreesGetHttpHeaderNamePointer(ds, index);
|
||||
global_51degrees.header_names->data = strlen(global_51degrees.header_names->area);
|
||||
global_51degrees.header_names[index].size = global_51degrees.header_names->data;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -615,8 +614,9 @@ static int init_51degrees(void)
|
||||
break;
|
||||
}
|
||||
if (_51d_dataset_status != DATA_SET_INIT_STATUS_SUCCESS) {
|
||||
if (temp->len)
|
||||
ha_alert("51Degrees Setup - Error reading 51Degrees data file. %s\n", temp->str);
|
||||
if (temp->data)
|
||||
ha_alert("51Degrees Setup - Error reading 51Degrees data file. %s\n",
|
||||
temp->area);
|
||||
else
|
||||
ha_alert("51Degrees Setup - Error reading 51Degrees data file.\n");
|
||||
return ERR_ALERT | ERR_FATAL;
|
||||
|
16
src/acl.c
16
src/acl.c
@ -113,9 +113,9 @@ static struct acl_expr *prune_acl_expr(struct acl_expr *expr)
|
||||
if (arg->type == ARGT_STOP)
|
||||
break;
|
||||
if (arg->type == ARGT_STR || arg->unresolved) {
|
||||
free(arg->data.str.str);
|
||||
arg->data.str.str = NULL;
|
||||
arg->data.str.len = 0;
|
||||
free(arg->data.str.area);
|
||||
arg->data.str.area = NULL;
|
||||
arg->data.str.data = 0;
|
||||
unresolved |= arg->unresolved;
|
||||
arg->unresolved = 0;
|
||||
}
|
||||
@ -525,11 +525,12 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
|
||||
}
|
||||
|
||||
/* Create displayed reference */
|
||||
snprintf(trash.str, trash.size, "acl '%s' file '%s' line %d", expr->kw, file, line);
|
||||
trash.str[trash.size - 1] = '\0';
|
||||
snprintf(trash.area, trash.size, "acl '%s' file '%s' line %d",
|
||||
expr->kw, file, line);
|
||||
trash.area[trash.size - 1] = '\0';
|
||||
|
||||
/* Create new patern reference. */
|
||||
ref = pat_ref_newid(unique_id, trash.str, PAT_REF_ACL);
|
||||
ref = pat_ref_newid(unique_id, trash.area, PAT_REF_ACL);
|
||||
if (!ref) {
|
||||
memprintf(err, "memory error");
|
||||
goto out_free_expr;
|
||||
@ -1272,7 +1273,8 @@ int acl_find_targets(struct proxy *p)
|
||||
*/
|
||||
if (expr->smp->arg_p->unresolved) {
|
||||
ha_alert("Internal bug in proxy %s: %sacl %s %s() makes use of unresolved userlist '%s'. Please report this.\n",
|
||||
p->id, *acl->name ? "" : "anonymous ", acl->name, expr->kw, expr->smp->arg_p->data.str.str);
|
||||
p->id, *acl->name ? "" : "anonymous ", acl->name, expr->kw,
|
||||
expr->smp->arg_p->data.str.area);
|
||||
cfgerr++;
|
||||
continue;
|
||||
}
|
||||
|
@ -174,9 +174,9 @@ int make_arg_list(const char *in, int len, uint64_t mask, struct arg **argp,
|
||||
* during the parsing. The caller must at one point resolve
|
||||
* them and free the string.
|
||||
*/
|
||||
arg->data.str.str = word;
|
||||
arg->data.str.len = in - beg;
|
||||
arg->data.str.size = arg->data.str.len + 1;
|
||||
arg->data.str.area = word;
|
||||
arg->data.str.data = in - beg;
|
||||
arg->data.str.size = arg->data.str.data + 1;
|
||||
word = NULL;
|
||||
break;
|
||||
|
||||
|
@ -277,7 +277,7 @@ pat_match_auth(struct sample *smp, struct pattern_expr *expr, int fill)
|
||||
|
||||
/* Browse the userlist for searching user. */
|
||||
for (u = ul->users; u; u = u->next) {
|
||||
if (strcmp(smp->data.u.str.str, u->user) == 0)
|
||||
if (strcmp(smp->data.u.str.area, u->user) == 0)
|
||||
break;
|
||||
}
|
||||
if (!u)
|
||||
|
@ -489,7 +489,7 @@ static struct server *get_server_rch(struct stream *s)
|
||||
c_rew(&s->req, rewind);
|
||||
|
||||
ret = fetch_rdp_cookie_name(s, &smp, px->hh_name, px->hh_len);
|
||||
len = smp.data.u.str.len;
|
||||
len = smp.data.u.str.data;
|
||||
|
||||
c_adv(&s->req, rewind);
|
||||
|
||||
@ -503,7 +503,7 @@ static struct server *get_server_rch(struct stream *s)
|
||||
/* Found a the hh_name in the headers.
|
||||
* we will compute the hash based on this value ctx.val.
|
||||
*/
|
||||
hash = gen_hash(px, smp.data.u.str.str, len);
|
||||
hash = gen_hash(px, smp.data.u.str.area, len);
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
@ -1013,7 +1013,7 @@ static void assign_tproxy_address(struct stream *s)
|
||||
case CO_SRC_TPROXY_DYN:
|
||||
if (src->bind_hdr_occ && s->txn) {
|
||||
char *vptr;
|
||||
int vlen;
|
||||
size_t vlen;
|
||||
int rewind;
|
||||
|
||||
/* bind to the IP in a header */
|
||||
@ -1270,7 +1270,8 @@ int connect_server(struct stream *s)
|
||||
c_adv(&s->req, rewind);
|
||||
|
||||
if (smp_make_safe(smp)) {
|
||||
ssl_sock_set_servername(srv_conn, smp->data.u.str.str);
|
||||
ssl_sock_set_servername(srv_conn,
|
||||
smp->data.u.str.area);
|
||||
srv_conn->flags |= CO_FL_PRIVATE;
|
||||
}
|
||||
}
|
||||
@ -1413,7 +1414,7 @@ int tcp_persist_rdp_cookie(struct stream *s, struct channel *req, int an_bit)
|
||||
memset(&smp, 0, sizeof(smp));
|
||||
|
||||
ret = fetch_rdp_cookie_name(s, &smp, s->be->rdp_cookie_name, s->be->rdp_cookie_len);
|
||||
if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.u.str.len == 0)
|
||||
if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.u.str.data == 0)
|
||||
goto no_cookie;
|
||||
|
||||
/* Considering an rdp cookie detected using acl, str ended with <cr><lf> and should return.
|
||||
@ -1421,7 +1422,7 @@ int tcp_persist_rdp_cookie(struct stream *s, struct channel *req, int an_bit)
|
||||
* server's IP address in network order, and "port" is the integer corresponding to the
|
||||
* server's port in network order. Comments please Emeric.
|
||||
*/
|
||||
addr = strtoul(smp.data.u.str.str, &p, 10);
|
||||
addr = strtoul(smp.data.u.str.area, &p, 10);
|
||||
if (*p != '.')
|
||||
goto no_cookie;
|
||||
p++;
|
||||
@ -1741,13 +1742,13 @@ smp_fetch_be_name(const struct arg *args, struct sample *smp, const char *kw, vo
|
||||
if (!smp->strm)
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str = (char *)smp->strm->be->id;
|
||||
if (!smp->data.u.str.str)
|
||||
smp->data.u.str.area = (char *)smp->strm->be->id;
|
||||
if (!smp->data.u.str.area)
|
||||
return 0;
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.u.str.len = strlen(smp->data.u.str.str);
|
||||
smp->data.u.str.data = strlen(smp->data.u.str.area);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1882,7 +1883,7 @@ static int sample_conv_nbsrv(const struct arg *args, struct sample *smp, void *p
|
||||
if (!smp_make_safe(smp))
|
||||
return 0;
|
||||
|
||||
px = proxy_find_by_name(smp->data.u.str.str, PR_CAP_BE, 0);
|
||||
px = proxy_find_by_name(smp->data.u.str.area, PR_CAP_BE, 0);
|
||||
if (!px)
|
||||
return 0;
|
||||
|
||||
|
@ -349,7 +349,7 @@ int http_calc_maxage(struct stream *s, struct cache *cache)
|
||||
|
||||
chunk_strncat(chk, value, ctx.vlen - 8 + 1);
|
||||
chunk_strncat(chk, "", 1);
|
||||
maxage = atoi(chk->str);
|
||||
maxage = atoi(chk->area);
|
||||
}
|
||||
|
||||
value = directive_value(ctx.line + ctx.val, ctx.vlen, "max-age", 7);
|
||||
@ -358,7 +358,7 @@ int http_calc_maxage(struct stream *s, struct cache *cache)
|
||||
|
||||
chunk_strncat(chk, value, ctx.vlen - 7 + 1);
|
||||
chunk_strncat(chk, "", 1);
|
||||
smaxage = atoi(chk->str);
|
||||
smaxage = atoi(chk->area);
|
||||
}
|
||||
}
|
||||
|
||||
@ -657,7 +657,7 @@ int sha1_hosturi(struct http_txn *txn)
|
||||
|
||||
/* hash everything */
|
||||
blk_SHA1_Init(&sha1_ctx);
|
||||
blk_SHA1_Update(&sha1_ctx, trash->str, trash->len);
|
||||
blk_SHA1_Update(&sha1_ctx, trash->area, trash->data);
|
||||
blk_SHA1_Final((unsigned char *)txn->cache_hash, &sha1_ctx);
|
||||
|
||||
return 1;
|
||||
|
@ -1778,10 +1778,10 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(trash.str, *env, delim - *env);
|
||||
trash.str[delim - *env] = 0;
|
||||
memcpy(trash.area, *env, delim - *env);
|
||||
trash.area[delim - *env] = 0;
|
||||
|
||||
if (unsetenv(trash.str) != 0) {
|
||||
if (unsetenv(trash.area) != 0) {
|
||||
ha_alert("parsing [%s:%d]: '%s' failed to unset variable '%s' : %s.\n", file, linenum, args[0], *env, strerror(errno));
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
|
59
src/checks.c
59
src/checks.c
@ -289,9 +289,9 @@ static void set_server_check_status(struct check *check, short status, const cha
|
||||
(check->health >= check->rise) ? check->fall : check->rise,
|
||||
(check->health >= check->rise) ? (s->uweight ? "UP" : "DRAIN") : "DOWN");
|
||||
|
||||
ha_warning("%s.\n", trash.str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
|
||||
send_email_alert(s, LOG_INFO, "%s", trash.str);
|
||||
ha_warning("%s.\n", trash.area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.area);
|
||||
send_email_alert(s, LOG_INFO, "%s", trash.area);
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,14 +434,16 @@ void __health_adjust(struct server *s, short status)
|
||||
|
||||
case HANA_ONERR_FAILCHK:
|
||||
/* simulate a failed health check */
|
||||
set_server_check_status(&s->check, HCHK_STATUS_HANA, trash.str);
|
||||
set_server_check_status(&s->check, HCHK_STATUS_HANA,
|
||||
trash.area);
|
||||
check_notify_failure(&s->check);
|
||||
break;
|
||||
|
||||
case HANA_ONERR_MARKDWN:
|
||||
/* mark server down */
|
||||
s->check.health = s->check.rise;
|
||||
set_server_check_status(&s->check, HCHK_STATUS_HANA, trash.str);
|
||||
set_server_check_status(&s->check, HCHK_STATUS_HANA,
|
||||
trash.area);
|
||||
check_notify_failure(&s->check);
|
||||
break;
|
||||
|
||||
@ -638,18 +640,21 @@ static void chk_report_conn_err(struct check *check, int errno_bck, int expired)
|
||||
|
||||
if (conn && conn->err_code) {
|
||||
if (errno && errno != EAGAIN)
|
||||
chunk_printf(&trash, "%s (%s)%s", conn_err_code_str(conn), strerror(errno), chk->str);
|
||||
chunk_printf(&trash, "%s (%s)%s", conn_err_code_str(conn), strerror(errno),
|
||||
chk->area);
|
||||
else
|
||||
chunk_printf(&trash, "%s%s", conn_err_code_str(conn), chk->str);
|
||||
err_msg = trash.str;
|
||||
chunk_printf(&trash, "%s%s", conn_err_code_str(conn),
|
||||
chk->area);
|
||||
err_msg = trash.area;
|
||||
}
|
||||
else {
|
||||
if (errno && errno != EAGAIN) {
|
||||
chunk_printf(&trash, "%s%s", strerror(errno), chk->str);
|
||||
err_msg = trash.str;
|
||||
chunk_printf(&trash, "%s%s", strerror(errno),
|
||||
chk->area);
|
||||
err_msg = trash.area;
|
||||
}
|
||||
else {
|
||||
err_msg = chk->str;
|
||||
err_msg = chk->area;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1112,14 +1117,15 @@ static void event_srv_chk_r(struct conn_stream *cs)
|
||||
hs, *msg ? " (" : "",
|
||||
msg, *msg ? ")" : "");
|
||||
|
||||
set_server_check_status(check, status, t->str);
|
||||
set_server_check_status(check, status, t->area);
|
||||
}
|
||||
else if (err && *err) {
|
||||
/* No status change but we'd like to report something odd.
|
||||
* Just report the current state and copy the message.
|
||||
*/
|
||||
chunk_printf(&trash, "agent reports an error : %s", err);
|
||||
set_server_check_status(check, status/*check->status*/, trash.str);
|
||||
set_server_check_status(check, status/*check->status*/,
|
||||
trash.area);
|
||||
|
||||
}
|
||||
else if (wrn && *wrn) {
|
||||
@ -1127,7 +1133,8 @@ static void event_srv_chk_r(struct conn_stream *cs)
|
||||
* Just report the current state and copy the message.
|
||||
*/
|
||||
chunk_printf(&trash, "agent warns : %s", wrn);
|
||||
set_server_check_status(check, status/*check->status*/, trash.str);
|
||||
set_server_check_status(check, status/*check->status*/,
|
||||
trash.area);
|
||||
}
|
||||
else
|
||||
set_server_check_status(check, status, NULL);
|
||||
@ -1530,7 +1537,8 @@ static int connect_conn_chk(struct task *t)
|
||||
}
|
||||
else if ((check->type) == PR_O2_HTTP_CHK) {
|
||||
if (s->proxy->options2 & PR_O2_CHK_SNDST)
|
||||
b_putblk(&check->bo, trash.str, httpchk_build_status_header(s, trash.str, trash.size));
|
||||
b_putblk(&check->bo, trash.area,
|
||||
httpchk_build_status_header(s, trash.area, trash.size));
|
||||
/* prevent HTTP keep-alive when "http-check expect" is used */
|
||||
if (s->proxy->options2 & PR_O2_EXP_TYPE)
|
||||
b_putist(&check->bo, ist("Connection: close\r\n"));
|
||||
@ -2729,7 +2737,8 @@ static int tcpcheck_main(struct check *check)
|
||||
comment = tcpcheck_get_step_comment(check, step);
|
||||
if (comment)
|
||||
chunk_appendf(&trash, " comment: '%s'", comment);
|
||||
set_server_check_status(check, HCHK_STATUS_SOCKERR, trash.str);
|
||||
set_server_check_status(check, HCHK_STATUS_SOCKERR,
|
||||
trash.area);
|
||||
check->current_step = NULL;
|
||||
goto out;
|
||||
}
|
||||
@ -2814,7 +2823,8 @@ static int tcpcheck_main(struct check *check)
|
||||
comment = tcpcheck_get_step_comment(check, step);
|
||||
if (comment)
|
||||
chunk_appendf(&trash, " comment: '%s'", comment);
|
||||
set_server_check_status(check, HCHK_STATUS_L4CON, trash.str);
|
||||
set_server_check_status(check, HCHK_STATUS_L4CON,
|
||||
trash.area);
|
||||
goto out_end_tcpcheck;
|
||||
case SF_ERR_PRXCOND:
|
||||
case SF_ERR_RESOURCE:
|
||||
@ -2824,7 +2834,8 @@ static int tcpcheck_main(struct check *check)
|
||||
comment = tcpcheck_get_step_comment(check, step);
|
||||
if (comment)
|
||||
chunk_appendf(&trash, " comment: '%s'", comment);
|
||||
set_server_check_status(check, HCHK_STATUS_SOCKERR, trash.str);
|
||||
set_server_check_status(check, HCHK_STATUS_SOCKERR,
|
||||
trash.area);
|
||||
goto out_end_tcpcheck;
|
||||
}
|
||||
|
||||
@ -2860,7 +2871,8 @@ static int tcpcheck_main(struct check *check)
|
||||
chunk_printf(&trash, "tcp-check send : string too large (%d) for buffer size (%u) at step %d",
|
||||
check->current_step->string_len, (unsigned int)b_size(&check->bo),
|
||||
tcpcheck_get_step_id(check));
|
||||
set_server_check_status(check, HCHK_STATUS_L7RSP, trash.str);
|
||||
set_server_check_status(check, HCHK_STATUS_L7RSP,
|
||||
trash.area);
|
||||
goto out_end_tcpcheck;
|
||||
}
|
||||
|
||||
@ -2930,7 +2942,8 @@ static int tcpcheck_main(struct check *check)
|
||||
comment = tcpcheck_get_step_comment(check, step);
|
||||
if (comment)
|
||||
chunk_appendf(&trash, " comment: '%s'", comment);
|
||||
set_server_check_status(check, HCHK_STATUS_L7RSP, trash.str);
|
||||
set_server_check_status(check, HCHK_STATUS_L7RSP,
|
||||
trash.area);
|
||||
|
||||
goto out_end_tcpcheck;
|
||||
}
|
||||
@ -2964,7 +2977,8 @@ static int tcpcheck_main(struct check *check)
|
||||
comment = tcpcheck_get_step_comment(check, step);
|
||||
if (comment)
|
||||
chunk_appendf(&trash, " comment: '%s'", comment);
|
||||
set_server_check_status(check, HCHK_STATUS_L7RSP, trash.str);
|
||||
set_server_check_status(check, HCHK_STATUS_L7RSP,
|
||||
trash.area);
|
||||
goto out_end_tcpcheck;
|
||||
}
|
||||
/* matched and was supposed to => OK, next step */
|
||||
@ -3019,7 +3033,8 @@ static int tcpcheck_main(struct check *check)
|
||||
comment = tcpcheck_get_step_comment(check, step);
|
||||
if (comment)
|
||||
chunk_appendf(&trash, " comment: '%s'", comment);
|
||||
set_server_check_status(check, HCHK_STATUS_L7RSP, trash.str);
|
||||
set_server_check_status(check, HCHK_STATUS_L7RSP,
|
||||
trash.area);
|
||||
goto out_end_tcpcheck;
|
||||
}
|
||||
}
|
||||
|
99
src/chunk.c
99
src/chunk.c
@ -35,7 +35,7 @@ static THREAD_LOCAL char *trash_buf2;
|
||||
struct pool_head *pool_head_trash = NULL;
|
||||
|
||||
/* this is used to drain data, and as a temporary buffer for sprintf()... */
|
||||
THREAD_LOCAL struct chunk trash = { .str = NULL };
|
||||
THREAD_LOCAL struct chunk trash = { };
|
||||
|
||||
/*
|
||||
* Returns a pre-allocated and initialized trash chunk that can be used for any
|
||||
@ -68,11 +68,11 @@ struct chunk *get_trash_chunk(void)
|
||||
*/
|
||||
static int alloc_trash_buffers(int bufsize)
|
||||
{
|
||||
chunk_init(&trash, my_realloc2(trash.str, bufsize), bufsize);
|
||||
chunk_init(&trash, my_realloc2(trash.area, bufsize), bufsize);
|
||||
trash_size = bufsize;
|
||||
trash_buf1 = (char *)my_realloc2(trash_buf1, bufsize);
|
||||
trash_buf2 = (char *)my_realloc2(trash_buf2, bufsize);
|
||||
return trash.str && trash_buf1 && trash_buf2;
|
||||
return trash.area && trash_buf1 && trash_buf2;
|
||||
}
|
||||
|
||||
static int init_trash_buffers_per_thread()
|
||||
@ -140,19 +140,19 @@ int chunk_printf(struct chunk *chk, const char *fmt, ...)
|
||||
va_list argp;
|
||||
int ret;
|
||||
|
||||
if (!chk->str || !chk->size)
|
||||
if (!chk->area || !chk->size)
|
||||
return 0;
|
||||
|
||||
va_start(argp, fmt);
|
||||
ret = vsnprintf(chk->str, chk->size, fmt, argp);
|
||||
ret = vsnprintf(chk->area, chk->size, fmt, argp);
|
||||
va_end(argp);
|
||||
chk->len = ret;
|
||||
chk->data = ret;
|
||||
|
||||
if (ret >= chk->size)
|
||||
ret = -1;
|
||||
|
||||
chk->len = ret;
|
||||
return chk->len;
|
||||
chk->data = ret;
|
||||
return chk->data;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -165,18 +165,19 @@ int chunk_appendf(struct chunk *chk, const char *fmt, ...)
|
||||
va_list argp;
|
||||
int ret;
|
||||
|
||||
if (chk->len < 0 || !chk->str || !chk->size)
|
||||
if (chk->data < 0 || !chk->area || !chk->size)
|
||||
return 0;
|
||||
|
||||
va_start(argp, fmt);
|
||||
ret = vsnprintf(chk->str + chk->len, chk->size - chk->len, fmt, argp);
|
||||
if (ret >= chk->size - chk->len)
|
||||
ret = vsnprintf(chk->area + chk->data, chk->size - chk->data, fmt,
|
||||
argp);
|
||||
if (ret >= chk->size - chk->data)
|
||||
/* do not copy anything in case of truncation */
|
||||
chk->str[chk->len] = 0;
|
||||
chk->area[chk->data] = 0;
|
||||
else
|
||||
chk->len += ret;
|
||||
chk->data += ret;
|
||||
va_end(argp);
|
||||
return chk->len;
|
||||
return chk->data;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -190,37 +191,38 @@ int chunk_htmlencode(struct chunk *dst, struct chunk *src)
|
||||
int olen, free;
|
||||
char c;
|
||||
|
||||
if (dst->len < 0)
|
||||
return dst->len;
|
||||
if (dst->data < 0)
|
||||
return dst->data;
|
||||
|
||||
olen = dst->len;
|
||||
olen = dst->data;
|
||||
|
||||
for (i = 0; i < src->len; i++) {
|
||||
free = dst->size - dst->len;
|
||||
for (i = 0; i < src->data; i++) {
|
||||
free = dst->size - dst->data;
|
||||
|
||||
if (!free) {
|
||||
dst->len = olen;
|
||||
return dst->len;
|
||||
dst->data = olen;
|
||||
return dst->data;
|
||||
}
|
||||
|
||||
c = src->str[i];
|
||||
c = src->area[i];
|
||||
|
||||
if (!isascii(c) || !isprint((unsigned char)c) || c == '&' || c == '"' || c == '\'' || c == '<' || c == '>') {
|
||||
l = snprintf(dst->str + dst->len, free, "&#%u;", (unsigned char)c);
|
||||
l = snprintf(dst->area + dst->data, free, "&#%u;",
|
||||
(unsigned char)c);
|
||||
|
||||
if (free < l) {
|
||||
dst->len = olen;
|
||||
return dst->len;
|
||||
dst->data = olen;
|
||||
return dst->data;
|
||||
}
|
||||
|
||||
dst->len += l;
|
||||
dst->data += l;
|
||||
} else {
|
||||
dst->str[dst->len] = c;
|
||||
dst->len++;
|
||||
dst->area[dst->data] = c;
|
||||
dst->data++;
|
||||
}
|
||||
}
|
||||
|
||||
return dst->len;
|
||||
return dst->data;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -234,37 +236,38 @@ int chunk_asciiencode(struct chunk *dst, struct chunk *src, char qc)
|
||||
int olen, free;
|
||||
char c;
|
||||
|
||||
if (dst->len < 0)
|
||||
return dst->len;
|
||||
if (dst->data < 0)
|
||||
return dst->data;
|
||||
|
||||
olen = dst->len;
|
||||
olen = dst->data;
|
||||
|
||||
for (i = 0; i < src->len; i++) {
|
||||
free = dst->size - dst->len;
|
||||
for (i = 0; i < src->data; i++) {
|
||||
free = dst->size - dst->data;
|
||||
|
||||
if (!free) {
|
||||
dst->len = olen;
|
||||
return dst->len;
|
||||
dst->data = olen;
|
||||
return dst->data;
|
||||
}
|
||||
|
||||
c = src->str[i];
|
||||
c = src->area[i];
|
||||
|
||||
if (!isascii(c) || !isprint((unsigned char)c) || c == '<' || c == '>' || c == qc) {
|
||||
l = snprintf(dst->str + dst->len, free, "<%02X>", (unsigned char)c);
|
||||
l = snprintf(dst->area + dst->data, free, "<%02X>",
|
||||
(unsigned char)c);
|
||||
|
||||
if (free < l) {
|
||||
dst->len = olen;
|
||||
return dst->len;
|
||||
dst->data = olen;
|
||||
return dst->data;
|
||||
}
|
||||
|
||||
dst->len += l;
|
||||
dst->data += l;
|
||||
} else {
|
||||
dst->str[dst->len] = c;
|
||||
dst->len++;
|
||||
dst->area[dst->data] = c;
|
||||
dst->data++;
|
||||
}
|
||||
}
|
||||
|
||||
return dst->len;
|
||||
return dst->data;
|
||||
}
|
||||
|
||||
/* Compares the string in chunk <chk> with the string in <str> which must be
|
||||
@ -273,8 +276,8 @@ int chunk_asciiencode(struct chunk *dst, struct chunk *src, char qc)
|
||||
*/
|
||||
int chunk_strcmp(const struct chunk *chk, const char *str)
|
||||
{
|
||||
const char *s1 = chk->str;
|
||||
int len = chk->len;
|
||||
const char *s1 = chk->area;
|
||||
int len = chk->data;
|
||||
int diff = 0;
|
||||
|
||||
do {
|
||||
@ -293,8 +296,8 @@ int chunk_strcmp(const struct chunk *chk, const char *str)
|
||||
*/
|
||||
int chunk_strcasecmp(const struct chunk *chk, const char *str)
|
||||
{
|
||||
const char *s1 = chk->str;
|
||||
int len = chk->len;
|
||||
const char *s1 = chk->area;
|
||||
int len = chk->data;
|
||||
int diff = 0;
|
||||
|
||||
do {
|
||||
|
33
src/cli.c
33
src/cli.c
@ -117,7 +117,7 @@ static char *cli_gen_usage_msg(struct appctx *appctx)
|
||||
}
|
||||
chunk_init(&out, NULL, 0);
|
||||
chunk_dup(&out, tmp);
|
||||
dynamic_usage_msg = out.str;
|
||||
dynamic_usage_msg = out.area;
|
||||
|
||||
end:
|
||||
if (dynamic_usage_msg) {
|
||||
@ -403,8 +403,8 @@ static int cli_parse_request(struct appctx *appctx)
|
||||
appctx->st2 = 0;
|
||||
memset(&appctx->ctx.cli, 0, sizeof(appctx->ctx.cli));
|
||||
|
||||
p = appctx->chunk->str;
|
||||
end = p + appctx->chunk->len;
|
||||
p = appctx->chunk->area;
|
||||
end = p + appctx->chunk->data;
|
||||
|
||||
/*
|
||||
* Get the payload start if there is one.
|
||||
@ -454,7 +454,7 @@ static int cli_parse_request(struct appctx *appctx)
|
||||
i++;
|
||||
}
|
||||
/* fill unused slots */
|
||||
p = appctx->chunk->str + appctx->chunk->len;
|
||||
p = appctx->chunk->area + appctx->chunk->data;
|
||||
for (; i < MAX_STATS_ARGS + 1; i++)
|
||||
args[i] = p;
|
||||
|
||||
@ -500,7 +500,7 @@ static int cli_output_msg(struct channel *chn, const char *msg, int severity, in
|
||||
}
|
||||
chunk_appendf(tmp, "%s", msg);
|
||||
|
||||
return ci_putblk(chn, tmp->str, strlen(tmp->str));
|
||||
return ci_putblk(chn, tmp->area, strlen(tmp->area));
|
||||
}
|
||||
|
||||
/* This I/O handler runs as an applet embedded in a stream interface. It is
|
||||
@ -557,7 +557,7 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
}
|
||||
}
|
||||
|
||||
str = appctx->chunk->str + appctx->chunk->len;
|
||||
str = appctx->chunk->area + appctx->chunk->data;
|
||||
|
||||
/* ensure we have some output room left in the event we
|
||||
* would want to return some info right after parsing.
|
||||
@ -568,7 +568,8 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
/* '- 1' is to ensure a null byte can always be inserted at the end */
|
||||
reql = co_getline(si_oc(si), str, appctx->chunk->size - appctx->chunk->len - 1);
|
||||
reql = co_getline(si_oc(si), str,
|
||||
appctx->chunk->size - appctx->chunk->data - 1);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
break;
|
||||
@ -607,12 +608,12 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
len--;
|
||||
|
||||
str[len] = '\0';
|
||||
appctx->chunk->len += len;
|
||||
appctx->chunk->data += len;
|
||||
|
||||
if (appctx->st1 & APPCTX_CLI_ST1_PAYLOAD) {
|
||||
appctx->chunk->str[appctx->chunk->len] = '\n';
|
||||
appctx->chunk->str[appctx->chunk->len + 1] = 0;
|
||||
appctx->chunk->len++;
|
||||
appctx->chunk->area[appctx->chunk->data] = '\n';
|
||||
appctx->chunk->area[appctx->chunk->data + 1] = 0;
|
||||
appctx->chunk->data++;
|
||||
}
|
||||
|
||||
appctx->st0 = CLI_ST_PROMPT;
|
||||
@ -621,8 +622,8 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
/* empty line */
|
||||
if (!len) {
|
||||
/* remove the last two \n */
|
||||
appctx->chunk->len -= 2;
|
||||
appctx->chunk->str[appctx->chunk->len] = 0;
|
||||
appctx->chunk->data -= 2;
|
||||
appctx->chunk->area[appctx->chunk->data] = 0;
|
||||
|
||||
if (!cli_parse_request(appctx))
|
||||
cli_gen_usage_msg(appctx);
|
||||
@ -641,7 +642,7 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
* Its location is not remembered here, this is just to switch
|
||||
* to a gathering mode.
|
||||
*/
|
||||
if (!strcmp(appctx->chunk->str + appctx->chunk->len - strlen(PAYLOAD_PATTERN), PAYLOAD_PATTERN))
|
||||
if (!strcmp(appctx->chunk->area + appctx->chunk->data - strlen(PAYLOAD_PATTERN), PAYLOAD_PATTERN))
|
||||
appctx->st1 |= APPCTX_CLI_ST1_PAYLOAD;
|
||||
else {
|
||||
/* no payload, the command is complete: parse the request */
|
||||
@ -705,7 +706,7 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
* when entering a payload with interactive mode, change the prompt
|
||||
* to emphasize that more data can still be sent
|
||||
*/
|
||||
if (appctx->chunk->len && appctx->st1 & APPCTX_CLI_ST1_PAYLOAD)
|
||||
if (appctx->chunk->data && appctx->st1 & APPCTX_CLI_ST1_PAYLOAD)
|
||||
prompt = "+ ";
|
||||
else
|
||||
prompt = "\n> ";
|
||||
@ -1053,7 +1054,7 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx)
|
||||
}
|
||||
}
|
||||
/* replace the latest comma by a newline */
|
||||
trash.str[trash.len-1] = '\n';
|
||||
trash.area[trash.data-1] = '\n';
|
||||
|
||||
} else {
|
||||
chunk_appendf(&trash, "all\n");
|
||||
|
@ -409,8 +409,9 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
return 0;
|
||||
|
||||
do {
|
||||
trash.len = recv(conn->handle.fd, trash.str, trash.size, MSG_PEEK);
|
||||
if (trash.len < 0) {
|
||||
trash.data = recv(conn->handle.fd, trash.area, trash.size,
|
||||
MSG_PEEK);
|
||||
if (trash.data < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
if (errno == EAGAIN) {
|
||||
@ -421,24 +422,24 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
}
|
||||
} while (0);
|
||||
|
||||
if (!trash.len) {
|
||||
if (!trash.data) {
|
||||
/* client shutdown */
|
||||
conn->err_code = CO_ER_PRX_EMPTY;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (trash.len < 6)
|
||||
if (trash.data < 6)
|
||||
goto missing;
|
||||
|
||||
line = trash.str;
|
||||
end = trash.str + trash.len;
|
||||
line = trash.area;
|
||||
end = trash.area + trash.data;
|
||||
|
||||
/* Decode a possible proxy request, fail early if it does not match */
|
||||
if (strncmp(line, "PROXY ", 6) != 0)
|
||||
goto not_v1;
|
||||
|
||||
line += 6;
|
||||
if (trash.len < 9) /* shortest possible line */
|
||||
if (trash.data < 9) /* shortest possible line */
|
||||
goto missing;
|
||||
|
||||
if (memcmp(line, "TCP4 ", 5) == 0) {
|
||||
@ -553,15 +554,15 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
trash.len = line - trash.str;
|
||||
trash.data = line - trash.area;
|
||||
goto eat_header;
|
||||
|
||||
not_v1:
|
||||
/* try PPv2 */
|
||||
if (trash.len < PP2_HEADER_LEN)
|
||||
if (trash.data < PP2_HEADER_LEN)
|
||||
goto missing;
|
||||
|
||||
hdr_v2 = (struct proxy_hdr_v2 *)trash.str;
|
||||
hdr_v2 = (struct proxy_hdr_v2 *) trash.area;
|
||||
|
||||
if (memcmp(hdr_v2->sig, v2sig, PP2_SIGNATURE_LEN) != 0 ||
|
||||
(hdr_v2->ver_cmd & PP2_VERSION_MASK) != PP2_VERSION) {
|
||||
@ -569,7 +570,7 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (trash.len < PP2_HEADER_LEN + ntohs(hdr_v2->len))
|
||||
if (trash.data < PP2_HEADER_LEN + ntohs(hdr_v2->len))
|
||||
goto missing;
|
||||
|
||||
switch (hdr_v2->ver_cmd & PP2_CMD_MASK) {
|
||||
@ -607,8 +608,8 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
|
||||
/* TLV parsing */
|
||||
if (tlv_length > 0) {
|
||||
while (tlv_offset + TLV_HEADER_SIZE <= trash.len) {
|
||||
const struct tlv *tlv_packet = (struct tlv *) &trash.str[tlv_offset];
|
||||
while (tlv_offset + TLV_HEADER_SIZE <= trash.data) {
|
||||
const struct tlv *tlv_packet = (struct tlv *) &trash.area[tlv_offset];
|
||||
const int tlv_len = get_tlv_length(tlv_packet);
|
||||
tlv_offset += tlv_len + TLV_HEADER_SIZE;
|
||||
|
||||
@ -617,7 +618,7 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
void *tlv_crc32c_p = (void *)tlv_packet->value;
|
||||
uint32_t n_crc32c = ntohl(read_u32(tlv_crc32c_p));
|
||||
write_u32(tlv_crc32c_p, 0);
|
||||
if (hash_crc32c(trash.str, PP2_HEADER_LEN + ntohs(hdr_v2->len)) != n_crc32c)
|
||||
if (hash_crc32c(trash.area, PP2_HEADER_LEN + ntohs(hdr_v2->len)) != n_crc32c)
|
||||
goto bad_header;
|
||||
break;
|
||||
}
|
||||
@ -645,7 +646,7 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
goto bad_header; /* not a supported command */
|
||||
}
|
||||
|
||||
trash.len = PP2_HEADER_LEN + ntohs(hdr_v2->len);
|
||||
trash.data = PP2_HEADER_LEN + ntohs(hdr_v2->len);
|
||||
goto eat_header;
|
||||
|
||||
eat_header:
|
||||
@ -654,10 +655,10 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
||||
* fail.
|
||||
*/
|
||||
do {
|
||||
int len2 = recv(conn->handle.fd, trash.str, trash.len, 0);
|
||||
int len2 = recv(conn->handle.fd, trash.area, trash.data, 0);
|
||||
if (len2 < 0 && errno == EINTR)
|
||||
continue;
|
||||
if (len2 != trash.len)
|
||||
if (len2 != trash.data)
|
||||
goto recv_abort;
|
||||
} while (0);
|
||||
|
||||
@ -722,8 +723,9 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
|
||||
return 0;
|
||||
|
||||
do {
|
||||
trash.len = recv(conn->handle.fd, trash.str, trash.size, MSG_PEEK);
|
||||
if (trash.len < 0) {
|
||||
trash.data = recv(conn->handle.fd, trash.area, trash.size,
|
||||
MSG_PEEK);
|
||||
if (trash.data < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
if (errno == EAGAIN) {
|
||||
@ -734,7 +736,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
|
||||
}
|
||||
} while (0);
|
||||
|
||||
if (!trash.len) {
|
||||
if (!trash.data) {
|
||||
/* client shutdown */
|
||||
conn->err_code = CO_ER_CIP_EMPTY;
|
||||
goto fail;
|
||||
@ -743,10 +745,10 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
|
||||
/* Fail if buffer length is not large enough to contain
|
||||
* CIP magic, header length or
|
||||
* CIP magic, CIP length, CIP type, header length */
|
||||
if (trash.len < 12)
|
||||
if (trash.data < 12)
|
||||
goto missing;
|
||||
|
||||
line = trash.str;
|
||||
line = trash.area;
|
||||
|
||||
/* Decode a possible NetScaler Client IP request, fail early if
|
||||
* it does not match */
|
||||
@ -754,12 +756,12 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
|
||||
goto bad_magic;
|
||||
|
||||
/* Legacy CIP protocol */
|
||||
if ((trash.str[8] & 0xD0) == 0x40) {
|
||||
if ((trash.area[8] & 0xD0) == 0x40) {
|
||||
hdr_len = ntohl(*(uint32_t *)(line+4));
|
||||
line += 8;
|
||||
}
|
||||
/* Standard CIP protocol */
|
||||
else if (trash.str[8] == 0x00) {
|
||||
else if (trash.area[8] == 0x00) {
|
||||
hdr_len = ntohs(*(uint32_t *)(line+10));
|
||||
line += 12;
|
||||
}
|
||||
@ -771,7 +773,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
|
||||
|
||||
/* Fail if buffer length is not large enough to contain
|
||||
* a minimal IP header */
|
||||
if (trash.len < 20)
|
||||
if (trash.data < 20)
|
||||
goto missing;
|
||||
|
||||
/* Get IP version from the first four bits */
|
||||
@ -783,7 +785,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
|
||||
|
||||
hdr_ip4 = (struct ip *)line;
|
||||
|
||||
if (trash.len < 40 || trash.len < hdr_len) {
|
||||
if (trash.data < 40 || trash.data < hdr_len) {
|
||||
/* Fail if buffer length is not large enough to contain
|
||||
* IPv4 header, TCP header */
|
||||
goto missing;
|
||||
@ -813,7 +815,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
|
||||
|
||||
hdr_ip6 = (struct ip6_hdr *)line;
|
||||
|
||||
if (trash.len < 60 || trash.len < hdr_len) {
|
||||
if (trash.data < 60 || trash.data < hdr_len) {
|
||||
/* Fail if buffer length is not large enough to contain
|
||||
* IPv6 header, TCP header */
|
||||
goto missing;
|
||||
@ -844,17 +846,17 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
|
||||
}
|
||||
|
||||
line += hdr_len;
|
||||
trash.len = line - trash.str;
|
||||
trash.data = line - trash.area;
|
||||
|
||||
/* remove the NetScaler Client IP header from the request. For this
|
||||
* we re-read the exact line at once. If we don't get the exact same
|
||||
* result, we fail.
|
||||
*/
|
||||
do {
|
||||
int len2 = recv(conn->handle.fd, trash.str, trash.len, 0);
|
||||
int len2 = recv(conn->handle.fd, trash.area, trash.data, 0);
|
||||
if (len2 < 0 && errno == EINTR)
|
||||
continue;
|
||||
if (len2 != trash.len)
|
||||
if (len2 != trash.data)
|
||||
goto recv_abort;
|
||||
} while (0);
|
||||
|
||||
@ -1096,13 +1098,17 @@ int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct connec
|
||||
if (srv->pp_opts & SRV_PP_V2_SSL_CN) {
|
||||
struct chunk *cn_trash = get_trash_chunk();
|
||||
if (ssl_sock_get_remote_common_name(remote, cn_trash) > 0) {
|
||||
ssl_tlv_len += make_tlv(&buf[ret+ssl_tlv_len], (buf_len - ret - ssl_tlv_len), PP2_SUBTYPE_SSL_CN, cn_trash->len, cn_trash->str);
|
||||
ssl_tlv_len += make_tlv(&buf[ret+ssl_tlv_len], (buf_len - ret - ssl_tlv_len), PP2_SUBTYPE_SSL_CN,
|
||||
cn_trash->data,
|
||||
cn_trash->area);
|
||||
}
|
||||
}
|
||||
if (srv->pp_opts & SRV_PP_V2_SSL_KEY_ALG) {
|
||||
struct chunk *pkey_trash = get_trash_chunk();
|
||||
if (ssl_sock_get_pkey_algo(remote, pkey_trash) > 0) {
|
||||
ssl_tlv_len += make_tlv(&buf[ret+ssl_tlv_len], (buf_len - ret - ssl_tlv_len), PP2_SUBTYPE_SSL_KEY_ALG, pkey_trash->len, pkey_trash->str);
|
||||
ssl_tlv_len += make_tlv(&buf[ret+ssl_tlv_len], (buf_len - ret - ssl_tlv_len), PP2_SUBTYPE_SSL_KEY_ALG,
|
||||
pkey_trash->data,
|
||||
pkey_trash->area);
|
||||
}
|
||||
}
|
||||
if (srv->pp_opts & SRV_PP_V2_SSL_SIG_ALG) {
|
||||
|
21
src/da.c
21
src/da.c
@ -193,10 +193,11 @@ static int da_haproxy(const struct arg *args, struct sample *smp, da_deviceinfo_
|
||||
tmp = get_trash_chunk();
|
||||
chunk_reset(tmp);
|
||||
|
||||
propname = (const char *)args[0].data.str.str;
|
||||
propname = (const char *) args[0].data.str.area;
|
||||
i = 0;
|
||||
|
||||
for (; propname != 0; i ++, propname = (const char *)args[i].data.str.str) {
|
||||
for (; propname != 0; i ++,
|
||||
propname = (const char *) args[i].data.str.area) {
|
||||
status = da_atlas_getpropid(&global_deviceatlas.atlas,
|
||||
propname, &prop);
|
||||
if (status != DA_OK) {
|
||||
@ -241,13 +242,13 @@ static int da_haproxy(const struct arg *args, struct sample *smp, da_deviceinfo_
|
||||
|
||||
da_close(devinfo);
|
||||
|
||||
if (tmp->len) {
|
||||
--tmp->len;
|
||||
tmp->str[tmp->len] = 0;
|
||||
if (tmp->data) {
|
||||
--tmp->data;
|
||||
tmp->area[tmp->data] = 0;
|
||||
}
|
||||
|
||||
smp->data.u.str.str = tmp->str;
|
||||
smp->data.u.str.len = tmp->len;
|
||||
smp->data.u.str.area = tmp->area;
|
||||
smp->data.u.str.data = tmp->data;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -260,12 +261,12 @@ static int da_haproxy_conv(const struct arg *args, struct sample *smp, void *pri
|
||||
char useragentbuf[1024] = { 0 };
|
||||
int i;
|
||||
|
||||
if (global_deviceatlas.daset == 0 || smp->data.u.str.len == 0) {
|
||||
if (global_deviceatlas.daset == 0 || smp->data.u.str.data == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
i = smp->data.u.str.len > sizeof(useragentbuf) ? sizeof(useragentbuf) : smp->data.u.str.len;
|
||||
memcpy(useragentbuf, smp->data.u.str.str, i - 1);
|
||||
i = smp->data.u.str.data > sizeof(useragentbuf) ? sizeof(useragentbuf) : smp->data.u.str.data;
|
||||
memcpy(useragentbuf, smp->data.u.str.area, i - 1);
|
||||
useragentbuf[i - 1] = 0;
|
||||
|
||||
useragent = (const char *)useragentbuf;
|
||||
|
15
src/dns.c
15
src/dns.c
@ -87,7 +87,8 @@ struct dns_srvrq *new_dns_srvrq(struct server *srv, char *fqdn)
|
||||
int fqdn_len, hostname_dn_len;
|
||||
|
||||
fqdn_len = strlen(fqdn);
|
||||
hostname_dn_len = dns_str_to_dn_label(fqdn, fqdn_len + 1, trash.str, trash.size);
|
||||
hostname_dn_len = dns_str_to_dn_label(fqdn, fqdn_len + 1, trash.area,
|
||||
trash.size);
|
||||
if (hostname_dn_len == -1) {
|
||||
ha_alert("config : %s '%s', server '%s': failed to parse FQDN '%s'\n",
|
||||
proxy_type_str(px), px->id, srv->id, fqdn);
|
||||
@ -102,7 +103,7 @@ struct dns_srvrq *new_dns_srvrq(struct server *srv, char *fqdn)
|
||||
srvrq->obj_type = OBJ_TYPE_SRVRQ;
|
||||
srvrq->proxy = px;
|
||||
srvrq->name = strdup(fqdn);
|
||||
srvrq->hostname_dn = strdup(trash.str);
|
||||
srvrq->hostname_dn = strdup(trash.area);
|
||||
srvrq->hostname_dn_len = hostname_dn_len;
|
||||
if (!srvrq->name || !srvrq->hostname_dn) {
|
||||
ha_alert("config : %s '%s', server '%s': out of memory\n",
|
||||
@ -1678,15 +1679,15 @@ static void dns_resolve_send(struct dgram_conn *dgram)
|
||||
if (res->nb_queries == resolvers->nb_nameservers)
|
||||
continue;
|
||||
|
||||
trash.len = dns_build_query(res->query_id, res->query_type,
|
||||
trash.data = dns_build_query(res->query_id, res->query_type,
|
||||
resolvers->accepted_payload_size,
|
||||
res->hostname_dn, res->hostname_dn_len,
|
||||
trash.str, trash.size);
|
||||
if (trash.len == -1)
|
||||
trash.area, trash.size);
|
||||
if (trash.data == -1)
|
||||
goto snd_error;
|
||||
|
||||
ret = send(fd, trash.str, trash.len, 0);
|
||||
if (ret != trash.len)
|
||||
ret = send(fd, trash.area, trash.data, 0);
|
||||
if (ret != trash.data)
|
||||
goto snd_error;
|
||||
|
||||
ns->counters.sent++;
|
||||
|
@ -565,12 +565,14 @@ select_compression_response_header(struct comp_state *st, struct stream *s, stru
|
||||
* header.
|
||||
*/
|
||||
if (st->comp_algo->cfg_name_len != 8 || memcmp(st->comp_algo->cfg_name, "identity", 8) != 0) {
|
||||
trash.len = 18;
|
||||
memcpy(trash.str, "Content-Encoding: ", trash.len);
|
||||
memcpy(trash.str + trash.len, st->comp_algo->ua_name, st->comp_algo->ua_name_len);
|
||||
trash.len += st->comp_algo->ua_name_len;
|
||||
trash.str[trash.len] = '\0';
|
||||
http_header_add_tail2(&txn->rsp, &txn->hdr_idx, trash.str, trash.len);
|
||||
trash.data = 18;
|
||||
memcpy(trash.area, "Content-Encoding: ", trash.data);
|
||||
memcpy(trash.area + trash.data, st->comp_algo->ua_name,
|
||||
st->comp_algo->ua_name_len);
|
||||
trash.data += st->comp_algo->ua_name_len;
|
||||
trash.area[trash.data] = '\0';
|
||||
http_header_add_tail2(&txn->rsp, &txn->hdr_idx, trash.area,
|
||||
trash.data);
|
||||
}
|
||||
msg->flags |= HTTP_MSGF_COMPRESSING;
|
||||
return 1;
|
||||
@ -977,8 +979,8 @@ smp_fetch_res_comp_algo(const struct arg *args, struct sample *smp,
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.u.str.str = st->comp_algo->cfg_name;
|
||||
smp->data.u.str.len = st->comp_algo->cfg_name_len;
|
||||
smp->data.u.str.area = st->comp_algo->cfg_name;
|
||||
smp->data.u.str.data = st->comp_algo->cfg_name_len;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -437,20 +437,20 @@ spoe_prepare_hahello_frame(struct appctx *appctx, char *frame, size_t size)
|
||||
*p++ = SPOE_DATA_T_STR;
|
||||
chk = get_trash_chunk();
|
||||
if (agent != NULL && (agent->flags & SPOE_FL_PIPELINING)) {
|
||||
memcpy(chk->str, "pipelining", 10);
|
||||
chk->len += 10;
|
||||
memcpy(chk->area, "pipelining", 10);
|
||||
chk->data += 10;
|
||||
}
|
||||
if (agent != NULL && (agent->flags & SPOE_FL_ASYNC)) {
|
||||
if (chk->len) chk->str[chk->len++] = ',';
|
||||
memcpy(chk->str+chk->len, "async", 5);
|
||||
chk->len += 5;
|
||||
if (chk->data) chk->area[chk->data++] = ',';
|
||||
memcpy(chk->area+chk->data, "async", 5);
|
||||
chk->data += 5;
|
||||
}
|
||||
if (agent != NULL && (agent->flags & SPOE_FL_RCV_FRAGMENTATION)) {
|
||||
if (chk->len) chk->str[chk->len++] = ',';
|
||||
memcpy(chk->str+chk->len, "fragmentation", 13);
|
||||
chk->len += 5;
|
||||
if (chk->data) chk->area[chk->data++] = ',';
|
||||
memcpy(chk->area+chk->data, "fragmentation", 13);
|
||||
chk->data += 5;
|
||||
}
|
||||
if (spoe_encode_buffer(chk->str, chk->len, &p, end) == -1)
|
||||
if (spoe_encode_buffer(chk->area, chk->data, &p, end) == -1)
|
||||
goto too_big;
|
||||
|
||||
/* (optionnal) "engine-id" K/V item, if present */
|
||||
@ -1361,7 +1361,7 @@ spoe_handle_connect_appctx(struct appctx *appctx)
|
||||
|
||||
/* 4 bytes are reserved at the beginning of <buf> to store the frame
|
||||
* length. */
|
||||
buf = trash.str; frame = buf+4;
|
||||
buf = trash.area; frame = buf+4;
|
||||
ret = spoe_prepare_hahello_frame(appctx, frame,
|
||||
SPOE_APPCTX(appctx)->max_frame_size);
|
||||
if (ret > 1)
|
||||
@ -1414,7 +1414,7 @@ spoe_handle_connecting_appctx(struct appctx *appctx)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
frame = trash.str; trash.len = 0;
|
||||
frame = trash.area; trash.data = 0;
|
||||
ret = spoe_recv_frame(appctx, frame,
|
||||
SPOE_APPCTX(appctx)->max_frame_size);
|
||||
if (ret > 1) {
|
||||
@ -1422,7 +1422,7 @@ spoe_handle_connecting_appctx(struct appctx *appctx)
|
||||
appctx->st0 = SPOE_APPCTX_ST_DISCONNECTING;
|
||||
goto next;
|
||||
}
|
||||
trash.len = ret + 4;
|
||||
trash.data = ret + 4;
|
||||
ret = spoe_handle_agenthello_frame(appctx, frame, ret);
|
||||
}
|
||||
|
||||
@ -1450,8 +1450,8 @@ spoe_handle_connecting_appctx(struct appctx *appctx)
|
||||
|
||||
next:
|
||||
/* Do not forget to remove processed frame from the output buffer */
|
||||
if (trash.len)
|
||||
co_skip(si_oc(si), trash.len);
|
||||
if (trash.data)
|
||||
co_skip(si_oc(si), trash.data);
|
||||
|
||||
SPOE_APPCTX(appctx)->task->expire =
|
||||
tick_add_ifset(now_ms, agent->timeout.idle);
|
||||
@ -1474,7 +1474,7 @@ spoe_handle_sending_frame_appctx(struct appctx *appctx, int *skip)
|
||||
|
||||
/* 4 bytes are reserved at the beginning of <buf> to store the frame
|
||||
* length. */
|
||||
buf = trash.str; frame = buf+4;
|
||||
buf = trash.area; frame = buf+4;
|
||||
|
||||
if (appctx->st0 == SPOE_APPCTX_ST_SENDING_FRAG_NOTIFY) {
|
||||
ctx = SPOE_APPCTX(appctx)->frag_ctx.ctx;
|
||||
@ -1592,7 +1592,7 @@ spoe_handle_receiving_frame_appctx(struct appctx *appctx, int *skip)
|
||||
char *frame;
|
||||
int ret;
|
||||
|
||||
frame = trash.str; trash.len = 0;
|
||||
frame = trash.area; trash.data = 0;
|
||||
ret = spoe_recv_frame(appctx, frame,
|
||||
SPOE_APPCTX(appctx)->max_frame_size);
|
||||
if (ret > 1) {
|
||||
@ -1601,7 +1601,7 @@ spoe_handle_receiving_frame_appctx(struct appctx *appctx, int *skip)
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
trash.len = ret + 4;
|
||||
trash.data = ret + 4;
|
||||
ret = spoe_handle_agentack_frame(appctx, &ctx, frame, ret);
|
||||
}
|
||||
switch (ret) {
|
||||
@ -1640,8 +1640,8 @@ spoe_handle_receiving_frame_appctx(struct appctx *appctx, int *skip)
|
||||
}
|
||||
|
||||
/* Do not forget to remove processed frame from the output buffer */
|
||||
if (trash.len)
|
||||
co_skip(si_oc(appctx->owner), trash.len);
|
||||
if (trash.data)
|
||||
co_skip(si_oc(appctx->owner), trash.data);
|
||||
end:
|
||||
return ret;
|
||||
}
|
||||
@ -1756,7 +1756,7 @@ spoe_handle_disconnect_appctx(struct appctx *appctx)
|
||||
|
||||
/* 4 bytes are reserved at the beginning of <buf> to store the frame
|
||||
* length. */
|
||||
buf = trash.str; frame = buf+4;
|
||||
buf = trash.area; frame = buf+4;
|
||||
ret = spoe_prepare_hadiscon_frame(appctx, frame,
|
||||
SPOE_APPCTX(appctx)->max_frame_size);
|
||||
if (ret > 1)
|
||||
@ -1810,11 +1810,11 @@ spoe_handle_disconnecting_appctx(struct appctx *appctx)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
frame = trash.str; trash.len = 0;
|
||||
frame = trash.area; trash.data = 0;
|
||||
ret = spoe_recv_frame(appctx, frame,
|
||||
SPOE_APPCTX(appctx)->max_frame_size);
|
||||
if (ret > 1) {
|
||||
trash.len = ret + 4;
|
||||
trash.data = ret + 4;
|
||||
ret = spoe_handle_agentdiscon_frame(appctx, frame, ret);
|
||||
}
|
||||
|
||||
@ -1846,8 +1846,8 @@ spoe_handle_disconnecting_appctx(struct appctx *appctx)
|
||||
|
||||
next:
|
||||
/* Do not forget to remove processed frame from the output buffer */
|
||||
if (trash.len)
|
||||
co_skip(si_oc(appctx->owner), trash.len);
|
||||
if (trash.data)
|
||||
co_skip(si_oc(appctx->owner), trash.data);
|
||||
|
||||
return 0;
|
||||
stop:
|
||||
@ -4141,12 +4141,12 @@ parse_spoe_flt(char **args, int *cur_arg, struct proxy *px,
|
||||
if (curagent->var_on_error) {
|
||||
struct arg arg;
|
||||
|
||||
trash.len = snprintf(trash.str, trash.size, "txn.%s.%s",
|
||||
trash.data = snprintf(trash.area, trash.size, "txn.%s.%s",
|
||||
curagent->var_pfx, curagent->var_on_error);
|
||||
|
||||
arg.type = ARGT_STR;
|
||||
arg.data.str.str = trash.str;
|
||||
arg.data.str.len = trash.len;
|
||||
arg.data.str.area = trash.area;
|
||||
arg.data.str.data = trash.data;
|
||||
if (!vars_check_arg(&arg, err)) {
|
||||
memprintf(err, "SPOE agent '%s': failed to register variable %s.%s (%s)",
|
||||
curagent->id, curagent->var_pfx, curagent->var_on_error, *err);
|
||||
@ -4157,12 +4157,12 @@ parse_spoe_flt(char **args, int *cur_arg, struct proxy *px,
|
||||
if (curagent->var_t_process) {
|
||||
struct arg arg;
|
||||
|
||||
trash.len = snprintf(trash.str, trash.size, "txn.%s.%s",
|
||||
trash.data = snprintf(trash.area, trash.size, "txn.%s.%s",
|
||||
curagent->var_pfx, curagent->var_t_process);
|
||||
|
||||
arg.type = ARGT_STR;
|
||||
arg.data.str.str = trash.str;
|
||||
arg.data.str.len = trash.len;
|
||||
arg.data.str.area = trash.area;
|
||||
arg.data.str.data = trash.data;
|
||||
if (!vars_check_arg(&arg, err)) {
|
||||
memprintf(err, "SPOE agent '%s': failed to register variable %s.%s (%s)",
|
||||
curagent->id, curagent->var_pfx, curagent->var_t_process, *err);
|
||||
@ -4173,12 +4173,12 @@ parse_spoe_flt(char **args, int *cur_arg, struct proxy *px,
|
||||
if (curagent->var_t_total) {
|
||||
struct arg arg;
|
||||
|
||||
trash.len = snprintf(trash.str, trash.size, "txn.%s.%s",
|
||||
trash.data = snprintf(trash.area, trash.size, "txn.%s.%s",
|
||||
curagent->var_pfx, curagent->var_t_total);
|
||||
|
||||
arg.type = ARGT_STR;
|
||||
arg.data.str.str = trash.str;
|
||||
arg.data.str.len = trash.len;
|
||||
arg.data.str.area = trash.area;
|
||||
arg.data.str.data = trash.data;
|
||||
if (!vars_check_arg(&arg, err)) {
|
||||
memprintf(err, "SPOE agent '%s': failed to register variable %s.%s (%s)",
|
||||
curagent->id, curagent->var_pfx, curagent->var_t_process, *err);
|
||||
@ -4378,12 +4378,12 @@ parse_spoe_flt(char **args, int *cur_arg, struct proxy *px,
|
||||
list_for_each_entry_safe(vph, vphback, &curvars, list) {
|
||||
struct arg arg;
|
||||
|
||||
trash.len = snprintf(trash.str, trash.size, "proc.%s.%s",
|
||||
trash.data = snprintf(trash.area, trash.size, "proc.%s.%s",
|
||||
curagent->var_pfx, vph->name);
|
||||
|
||||
arg.type = ARGT_STR;
|
||||
arg.data.str.str = trash.str;
|
||||
arg.data.str.len = trash.len;
|
||||
arg.data.str.area = trash.area;
|
||||
arg.data.str.data = trash.data;
|
||||
if (!vars_check_arg(&arg, err)) {
|
||||
memprintf(err, "SPOE agent '%s': failed to register variable %s.%s (%s)",
|
||||
curagent->id, curagent->var_pfx, vph->name, *err);
|
||||
|
@ -124,7 +124,7 @@ int frontend_accept(struct stream *s)
|
||||
break;
|
||||
}
|
||||
|
||||
shut_your_big_mouth_gcc(write(1, trash.str, trash.len));
|
||||
shut_your_big_mouth_gcc(write(1, trash.area, trash.data));
|
||||
}
|
||||
|
||||
if (fe->mode == PR_MODE_HTTP)
|
||||
@ -184,13 +184,13 @@ smp_fetch_fe_id(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
static int
|
||||
smp_fetch_fe_name(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->data.u.str.str = (char *)smp->sess->fe->id;
|
||||
if (!smp->data.u.str.str)
|
||||
smp->data.u.str.area = (char *)smp->sess->fe->id;
|
||||
if (!smp->data.u.str.area)
|
||||
return 0;
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.u.str.len = strlen(smp->data.u.str.str);
|
||||
smp->data.u.str.data = strlen(smp->data.u.str.area);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -200,13 +200,13 @@ smp_fetch_fe_defbe(const struct arg *args, struct sample *smp, const char *kw, v
|
||||
{
|
||||
if (!smp->sess->fe->defbe.be)
|
||||
return 0;
|
||||
smp->data.u.str.str = (char *)smp->sess->fe->defbe.be->id;
|
||||
if (!smp->data.u.str.str)
|
||||
smp->data.u.str.area = (char *)smp->sess->fe->defbe.be->id;
|
||||
if (!smp->data.u.str.area)
|
||||
return 0;
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.u.str.len = strlen(smp->data.u.str.str);
|
||||
smp->data.u.str.data = strlen(smp->data.u.str.area);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -852,8 +852,8 @@ static void sig_dump_state(struct sig_handler *sh)
|
||||
p->id, s->id,
|
||||
(s->cur_state != SRV_ST_STOPPED) ? "UP" : "DOWN",
|
||||
s->cur_sess, s->nbpend, s->counters.cum_sess);
|
||||
ha_warning("%s\n", trash.str);
|
||||
send_log(p, LOG_NOTICE, "%s\n", trash.str);
|
||||
ha_warning("%s\n", trash.area);
|
||||
send_log(p, LOG_NOTICE, "%s\n", trash.area);
|
||||
s = s->next;
|
||||
}
|
||||
|
||||
@ -876,8 +876,8 @@ static void sig_dump_state(struct sig_handler *sh)
|
||||
p->id, p->srv_act, p->srv_bck,
|
||||
p->feconn, p->beconn, p->totpend, p->nbpend, p->fe_counters.cum_conn, p->be_counters.cum_conn);
|
||||
}
|
||||
ha_warning("%s\n", trash.str);
|
||||
send_log(p, LOG_NOTICE, "%s\n", trash.str);
|
||||
ha_warning("%s\n", trash.area);
|
||||
send_log(p, LOG_NOTICE, "%s\n", trash.area);
|
||||
|
||||
p = p->next;
|
||||
}
|
||||
|
168
src/hlua.c
168
src/hlua.c
@ -340,7 +340,7 @@ __LJMP static const char *hlua_traceback(lua_State *L)
|
||||
chunk_appendf(msg, " ...");
|
||||
}
|
||||
|
||||
return msg->str;
|
||||
return msg->area;
|
||||
}
|
||||
|
||||
|
||||
@ -386,7 +386,7 @@ static int hlua_arg2lua(lua_State *L, const struct arg *arg)
|
||||
break;
|
||||
|
||||
case ARGT_STR:
|
||||
lua_pushlstring(L, arg->data.str.str, arg->data.str.len);
|
||||
lua_pushlstring(L, arg->data.str.area, arg->data.str.data);
|
||||
break;
|
||||
|
||||
case ARGT_IPV4:
|
||||
@ -423,7 +423,7 @@ static int hlua_lua2arg(lua_State *L, int ud, struct arg *arg)
|
||||
|
||||
case LUA_TSTRING:
|
||||
arg->type = ARGT_STR;
|
||||
arg->data.str.str = (char *)lua_tolstring(L, ud, (size_t *)&arg->data.str.len);
|
||||
arg->data.str.area = (char *)lua_tolstring(L, ud, (size_t *)&arg->data.str.data);
|
||||
break;
|
||||
|
||||
case LUA_TUSERDATA:
|
||||
@ -453,7 +453,7 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp)
|
||||
|
||||
case SMP_T_BIN:
|
||||
case SMP_T_STR:
|
||||
lua_pushlstring(L, smp->data.u.str.str, smp->data.u.str.len);
|
||||
lua_pushlstring(L, smp->data.u.str.area, smp->data.u.str.data);
|
||||
break;
|
||||
|
||||
case SMP_T_METH:
|
||||
@ -467,7 +467,7 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp)
|
||||
case HTTP_METH_TRACE: lua_pushstring(L, "TRACE"); break;
|
||||
case HTTP_METH_CONNECT: lua_pushstring(L, "CONNECT"); break;
|
||||
case HTTP_METH_OTHER:
|
||||
lua_pushlstring(L, smp->data.u.meth.str.str, smp->data.u.meth.str.len);
|
||||
lua_pushlstring(L, smp->data.u.meth.str.area, smp->data.u.meth.str.data);
|
||||
break;
|
||||
default:
|
||||
lua_pushnil(L);
|
||||
@ -480,7 +480,7 @@ static int hlua_smp2lua(lua_State *L, struct sample *smp)
|
||||
case SMP_T_ADDR: /* This type is never used to qualify a sample. */
|
||||
if (sample_casts[smp->data.type][SMP_T_STR] &&
|
||||
sample_casts[smp->data.type][SMP_T_STR](smp))
|
||||
lua_pushlstring(L, smp->data.u.str.str, smp->data.u.str.len);
|
||||
lua_pushlstring(L, smp->data.u.str.area, smp->data.u.str.data);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
break;
|
||||
@ -501,7 +501,7 @@ static int hlua_smp2lua_str(lua_State *L, struct sample *smp)
|
||||
|
||||
case SMP_T_BIN:
|
||||
case SMP_T_STR:
|
||||
lua_pushlstring(L, smp->data.u.str.str, smp->data.u.str.len);
|
||||
lua_pushlstring(L, smp->data.u.str.area, smp->data.u.str.data);
|
||||
break;
|
||||
|
||||
case SMP_T_METH:
|
||||
@ -515,7 +515,7 @@ static int hlua_smp2lua_str(lua_State *L, struct sample *smp)
|
||||
case HTTP_METH_TRACE: lua_pushstring(L, "TRACE"); break;
|
||||
case HTTP_METH_CONNECT: lua_pushstring(L, "CONNECT"); break;
|
||||
case HTTP_METH_OTHER:
|
||||
lua_pushlstring(L, smp->data.u.meth.str.str, smp->data.u.meth.str.len);
|
||||
lua_pushlstring(L, smp->data.u.meth.str.area, smp->data.u.meth.str.data);
|
||||
break;
|
||||
default:
|
||||
lua_pushstring(L, "");
|
||||
@ -530,7 +530,7 @@ static int hlua_smp2lua_str(lua_State *L, struct sample *smp)
|
||||
case SMP_T_ADDR: /* This type is never used to qualify a sample. */
|
||||
if (sample_casts[smp->data.type][SMP_T_STR] &&
|
||||
sample_casts[smp->data.type][SMP_T_STR](smp))
|
||||
lua_pushlstring(L, smp->data.u.str.str, smp->data.u.str.len);
|
||||
lua_pushlstring(L, smp->data.u.str.area, smp->data.u.str.data);
|
||||
else
|
||||
lua_pushstring(L, "");
|
||||
break;
|
||||
@ -563,7 +563,7 @@ static int hlua_lua2smp(lua_State *L, int ud, struct sample *smp)
|
||||
case LUA_TSTRING:
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.u.str.str = (char *)lua_tolstring(L, ud, (size_t *)&smp->data.u.str.len);
|
||||
smp->data.u.str.area = (char *)lua_tolstring(L, ud, (size_t *)&smp->data.u.str.data);
|
||||
break;
|
||||
|
||||
case LUA_TUSERDATA:
|
||||
@ -684,9 +684,10 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
|
||||
case ARGT_FE:
|
||||
if (argp[idx].type != ARGT_STR)
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "string expected"));
|
||||
memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len);
|
||||
trash.str[argp[idx].data.str.len] = 0;
|
||||
argp[idx].data.prx = proxy_fe_by_name(trash.str);
|
||||
memcpy(trash.area, argp[idx].data.str.area,
|
||||
argp[idx].data.str.data);
|
||||
trash.area[argp[idx].data.str.data] = 0;
|
||||
argp[idx].data.prx = proxy_fe_by_name(trash.area);
|
||||
if (!argp[idx].data.prx)
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "frontend doesn't exist"));
|
||||
argp[idx].type = ARGT_FE;
|
||||
@ -695,9 +696,10 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
|
||||
case ARGT_BE:
|
||||
if (argp[idx].type != ARGT_STR)
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "string expected"));
|
||||
memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len);
|
||||
trash.str[argp[idx].data.str.len] = 0;
|
||||
argp[idx].data.prx = proxy_be_by_name(trash.str);
|
||||
memcpy(trash.area, argp[idx].data.str.area,
|
||||
argp[idx].data.str.data);
|
||||
trash.area[argp[idx].data.str.data] = 0;
|
||||
argp[idx].data.prx = proxy_be_by_name(trash.area);
|
||||
if (!argp[idx].data.prx)
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "backend doesn't exist"));
|
||||
argp[idx].type = ARGT_BE;
|
||||
@ -706,9 +708,10 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
|
||||
case ARGT_TAB:
|
||||
if (argp[idx].type != ARGT_STR)
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "string expected"));
|
||||
memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len);
|
||||
trash.str[argp[idx].data.str.len] = 0;
|
||||
argp[idx].data.prx = proxy_tbl_by_name(trash.str);
|
||||
memcpy(trash.area, argp[idx].data.str.area,
|
||||
argp[idx].data.str.data);
|
||||
trash.area[argp[idx].data.str.data] = 0;
|
||||
argp[idx].data.prx = proxy_tbl_by_name(trash.area);
|
||||
if (!argp[idx].data.prx)
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "table doesn't exist"));
|
||||
argp[idx].type = ARGT_TAB;
|
||||
@ -717,18 +720,19 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
|
||||
case ARGT_SRV:
|
||||
if (argp[idx].type != ARGT_STR)
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "string expected"));
|
||||
memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len);
|
||||
trash.str[argp[idx].data.str.len] = 0;
|
||||
sname = strrchr(trash.str, '/');
|
||||
memcpy(trash.area, argp[idx].data.str.area,
|
||||
argp[idx].data.str.data);
|
||||
trash.area[argp[idx].data.str.data] = 0;
|
||||
sname = strrchr(trash.area, '/');
|
||||
if (sname) {
|
||||
*sname++ = '\0';
|
||||
pname = trash.str;
|
||||
pname = trash.area;
|
||||
px = proxy_be_by_name(pname);
|
||||
if (!px)
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "backend doesn't exist"));
|
||||
}
|
||||
else {
|
||||
sname = trash.str;
|
||||
sname = trash.area;
|
||||
px = p;
|
||||
}
|
||||
argp[idx].data.srv = findserver(px, sname);
|
||||
@ -738,33 +742,37 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
|
||||
break;
|
||||
|
||||
case ARGT_IPV4:
|
||||
memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len);
|
||||
trash.str[argp[idx].data.str.len] = 0;
|
||||
if (inet_pton(AF_INET, trash.str, &argp[idx].data.ipv4))
|
||||
memcpy(trash.area, argp[idx].data.str.area,
|
||||
argp[idx].data.str.data);
|
||||
trash.area[argp[idx].data.str.data] = 0;
|
||||
if (inet_pton(AF_INET, trash.area, &argp[idx].data.ipv4))
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "invalid IPv4 address"));
|
||||
argp[idx].type = ARGT_IPV4;
|
||||
break;
|
||||
|
||||
case ARGT_MSK4:
|
||||
memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len);
|
||||
trash.str[argp[idx].data.str.len] = 0;
|
||||
if (!str2mask(trash.str, &argp[idx].data.ipv4))
|
||||
memcpy(trash.area, argp[idx].data.str.area,
|
||||
argp[idx].data.str.data);
|
||||
trash.area[argp[idx].data.str.data] = 0;
|
||||
if (!str2mask(trash.area, &argp[idx].data.ipv4))
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "invalid IPv4 mask"));
|
||||
argp[idx].type = ARGT_MSK4;
|
||||
break;
|
||||
|
||||
case ARGT_IPV6:
|
||||
memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len);
|
||||
trash.str[argp[idx].data.str.len] = 0;
|
||||
if (inet_pton(AF_INET6, trash.str, &argp[idx].data.ipv6))
|
||||
memcpy(trash.area, argp[idx].data.str.area,
|
||||
argp[idx].data.str.data);
|
||||
trash.area[argp[idx].data.str.data] = 0;
|
||||
if (inet_pton(AF_INET6, trash.area, &argp[idx].data.ipv6))
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "invalid IPv6 address"));
|
||||
argp[idx].type = ARGT_IPV6;
|
||||
break;
|
||||
|
||||
case ARGT_MSK6:
|
||||
memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len);
|
||||
trash.str[argp[idx].data.str.len] = 0;
|
||||
if (!str2mask6(trash.str, &argp[idx].data.ipv6))
|
||||
memcpy(trash.area, argp[idx].data.str.area,
|
||||
argp[idx].data.str.data);
|
||||
trash.area[argp[idx].data.str.data] = 0;
|
||||
if (!str2mask6(trash.area, &argp[idx].data.ipv6))
|
||||
WILL_LJMP(luaL_argerror(L, first + idx, "invalid IPv6 mask"));
|
||||
argp[idx].type = ARGT_MSK6;
|
||||
break;
|
||||
@ -817,9 +825,9 @@ static inline void hlua_sendlog(struct proxy *px, int level, const char *msg)
|
||||
char *p;
|
||||
|
||||
/* Cleanup the log message. */
|
||||
p = trash.str;
|
||||
p = trash.area;
|
||||
for (; *msg != '\0'; msg++, p++) {
|
||||
if (p >= trash.str + trash.size - 1) {
|
||||
if (p >= trash.area + trash.size - 1) {
|
||||
/* Break the message if exceed the buffer size. */
|
||||
*(p-4) = ' ';
|
||||
*(p-3) = '.';
|
||||
@ -834,12 +842,12 @@ static inline void hlua_sendlog(struct proxy *px, int level, const char *msg)
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
send_log(px, level, "%s\n", trash.str);
|
||||
send_log(px, level, "%s\n", trash.area);
|
||||
if (!(global.mode & MODE_QUIET) || (global.mode & (MODE_VERBOSE | MODE_STARTING))) {
|
||||
get_localtime(date.tv_sec, &tm);
|
||||
fprintf(stderr, "[%s] %03d/%02d%02d%02d (%d) : %s\n",
|
||||
log_levels[level], tm.tm_yday, tm.tm_hour, tm.tm_min, tm.tm_sec,
|
||||
(int)getpid(), trash.str);
|
||||
(int)getpid(), trash.area);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
@ -1479,7 +1487,7 @@ __LJMP static int hlua_map_new(struct lua_State *L)
|
||||
|
||||
/* fill fake args. */
|
||||
args[0].type = ARGT_STR;
|
||||
args[0].data.str.str = (char *)fn;
|
||||
args[0].data.str.area = (char *)fn;
|
||||
args[1].type = ARGT_STOP;
|
||||
|
||||
/* load the map. */
|
||||
@ -1522,7 +1530,7 @@ __LJMP static inline int _hlua_map_lookup(struct lua_State *L, int str)
|
||||
else {
|
||||
smp.data.type = SMP_T_STR;
|
||||
smp.flags = SMP_F_CONST;
|
||||
smp.data.u.str.str = (char *)MAY_LJMP(luaL_checklstring(L, 2, (size_t *)&smp.data.u.str.len));
|
||||
smp.data.u.str.area = (char *)MAY_LJMP(luaL_checklstring(L, 2, (size_t *)&smp.data.u.str.data));
|
||||
}
|
||||
|
||||
pat = pattern_exec_match(&desc->pat, &smp, 1);
|
||||
@ -1535,7 +1543,7 @@ __LJMP static inline int _hlua_map_lookup(struct lua_State *L, int str)
|
||||
}
|
||||
|
||||
/* The Lua pattern must return a string, so we can't check the returned type */
|
||||
lua_pushlstring(L, pat->data->u.str.str, pat->data->u.str.len);
|
||||
lua_pushlstring(L, pat->data->u.str.area, pat->data->u.str.data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3041,7 +3049,7 @@ __LJMP static int hlua_channel_send_yield(lua_State *L, int status, lua_KContext
|
||||
* detects a non contiguous buffer and realign it.
|
||||
*/
|
||||
if (ci_space_for_replace(chn) < max)
|
||||
channel_slow_realign(chn, trash.str);
|
||||
channel_slow_realign(chn, trash.area);
|
||||
|
||||
/* Copy input data in the buffer. */
|
||||
max = b_rep_blk(&chn->buf, ci_head(chn), ci_head(chn), str + l, max);
|
||||
@ -3279,7 +3287,7 @@ __LJMP static int hlua_run_sample_fetch(lua_State *L)
|
||||
hlua_lua2arg(L, i + 2, &args[i]);
|
||||
}
|
||||
args[i].type = ARGT_STOP;
|
||||
args[i].data.str.str = NULL;
|
||||
args[i].data.str.area = NULL;
|
||||
|
||||
/* Check arguments. */
|
||||
MAY_LJMP(hlua_lua2arg_check(L, 2, args, f->arg_mask, hsmp->p));
|
||||
@ -3385,7 +3393,7 @@ __LJMP static int hlua_run_sample_conv(lua_State *L)
|
||||
hlua_lua2arg(L, i + 3, &args[i]);
|
||||
}
|
||||
args[i].type = ARGT_STOP;
|
||||
args[i].data.str.str = NULL;
|
||||
args[i].data.str.area = NULL;
|
||||
|
||||
/* Check arguments. */
|
||||
MAY_LJMP(hlua_lua2arg_check(L, 3, args, conv->arg_mask, hsmp->p));
|
||||
@ -4533,16 +4541,17 @@ __LJMP static int hlua_applet_http_start_response(lua_State *L)
|
||||
value = lua_tolstring(L, -1, &value_len);
|
||||
|
||||
/* Catenate a new header. */
|
||||
if (tmp->len + name_len + 2 + value_len + 2 < tmp->size) {
|
||||
memcpy(tmp->str + tmp->len, name, name_len);
|
||||
tmp->len += name_len;
|
||||
tmp->str[tmp->len++] = ':';
|
||||
tmp->str[tmp->len++] = ' ';
|
||||
if (tmp->data + name_len + 2 + value_len + 2 < tmp->size) {
|
||||
memcpy(tmp->area + tmp->data, name, name_len);
|
||||
tmp->data += name_len;
|
||||
tmp->area[tmp->data++] = ':';
|
||||
tmp->area[tmp->data++] = ' ';
|
||||
|
||||
memcpy(tmp->str + tmp->len, value, value_len);
|
||||
tmp->len += value_len;
|
||||
tmp->str[tmp->len++] = '\r';
|
||||
tmp->str[tmp->len++] = '\n';
|
||||
memcpy(tmp->area + tmp->data, value,
|
||||
value_len);
|
||||
tmp->data += value_len;
|
||||
tmp->area[tmp->data++] = '\r';
|
||||
tmp->area[tmp->data++] = '\n';
|
||||
}
|
||||
|
||||
/* Protocol checks. */
|
||||
@ -4591,7 +4600,7 @@ __LJMP static int hlua_applet_http_start_response(lua_State *L)
|
||||
lua_pop(L, 2);
|
||||
|
||||
/* Push the headers block. */
|
||||
lua_pushlstring(L, tmp->str, tmp->len);
|
||||
lua_pushlstring(L, tmp->area, tmp->data);
|
||||
|
||||
return MAY_LJMP(hlua_applet_http_start_response_yield(L, 0, 0));
|
||||
}
|
||||
@ -4705,7 +4714,7 @@ __LJMP static int hlua_http_get_headers(lua_State *L, struct hlua_txn *htxn, str
|
||||
* the size of one buffer and the input data contains in one
|
||||
* buffer.
|
||||
*/
|
||||
out = trash.str;
|
||||
out = trash.area;
|
||||
for (in=hn; in<hn+hnl; in++, out++)
|
||||
*out = tolower(*in);
|
||||
*out = '\0';
|
||||
@ -4715,7 +4724,7 @@ __LJMP static int hlua_http_get_headers(lua_State *L, struct hlua_txn *htxn, str
|
||||
* push the key in the stack, the function lua_gettable()
|
||||
* perform the lookup.
|
||||
*/
|
||||
lua_pushlstring(L, trash.str, hnl);
|
||||
lua_pushlstring(L, trash.area, hnl);
|
||||
lua_gettable(L, -2);
|
||||
type = lua_type(L, -1);
|
||||
|
||||
@ -4723,7 +4732,7 @@ __LJMP static int hlua_http_get_headers(lua_State *L, struct hlua_txn *htxn, str
|
||||
case LUA_TNIL:
|
||||
/* Table not found, create it. */
|
||||
lua_pop(L, 1); /* remove the nil value. */
|
||||
lua_pushlstring(L, trash.str, hnl); /* push the header name as key. */
|
||||
lua_pushlstring(L, trash.area, hnl); /* push the header name as key. */
|
||||
lua_newtable(L); /* create and push empty table. */
|
||||
lua_pushlstring(L, hv, hvl); /* push header value. */
|
||||
lua_rawseti(L, -2, 0); /* index header value (pop it). */
|
||||
@ -4889,12 +4898,12 @@ __LJMP static inline int hlua_http_add_hdr(lua_State *L, struct hlua_txn *htxn,
|
||||
return 0;
|
||||
|
||||
/* Check length. */
|
||||
trash.len = value_len + name_len + 2;
|
||||
if (trash.len > trash.size)
|
||||
trash.data = value_len + name_len + 2;
|
||||
if (trash.data > trash.size)
|
||||
return 0;
|
||||
|
||||
/* Creates the header string. */
|
||||
p = trash.str;
|
||||
p = trash.area;
|
||||
memcpy(p, name, name_len);
|
||||
p += name_len;
|
||||
*p = ':';
|
||||
@ -4904,7 +4913,7 @@ __LJMP static inline int hlua_http_add_hdr(lua_State *L, struct hlua_txn *htxn,
|
||||
memcpy(p, value, value_len);
|
||||
|
||||
lua_pushboolean(L, http_header_add_tail2(msg, &htxn->s->txn->hdr_idx,
|
||||
trash.str, trash.len) != 0);
|
||||
trash.area, trash.data) != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -5006,11 +5015,12 @@ static int hlua_http_req_set_query(lua_State *L)
|
||||
|
||||
/* Add the mark question as prefix. */
|
||||
chunk_reset(&trash);
|
||||
trash.str[trash.len++] = '?';
|
||||
memcpy(trash.str + trash.len, name, name_len);
|
||||
trash.len += name_len;
|
||||
trash.area[trash.data++] = '?';
|
||||
memcpy(trash.area + trash.data, name, name_len);
|
||||
trash.data += name_len;
|
||||
|
||||
lua_pushboolean(L, http_replace_req_line(2, trash.str, trash.len, htxn->p, htxn->s) != -1);
|
||||
lua_pushboolean(L,
|
||||
http_replace_req_line(2, trash.area, trash.data, htxn->p, htxn->s) != -1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -5837,7 +5847,7 @@ static int hlua_sample_fetch_wrapper(const struct arg *arg_p, struct sample *smp
|
||||
struct hlua_function *fcn = private;
|
||||
struct stream *stream = smp->strm;
|
||||
const char *error;
|
||||
const struct chunk msg = { .len = 0 };
|
||||
const struct chunk msg = { };
|
||||
|
||||
if (!stream)
|
||||
return 0;
|
||||
@ -6106,7 +6116,7 @@ static enum act_return hlua_action(struct act_rule *rule, struct proxy *px,
|
||||
unsigned int analyzer;
|
||||
int dir;
|
||||
const char *error;
|
||||
const struct chunk msg = { .len = 0 };
|
||||
const struct chunk msg = { };
|
||||
|
||||
switch (rule->from) {
|
||||
case ACT_F_TCP_REQ_CNT: analyzer = AN_REQ_INSPECT_FE ; dir = SMP_OPT_DIR_REQ; break;
|
||||
@ -7654,8 +7664,8 @@ void hlua_init(void)
|
||||
for (i=0; i<PAT_MATCH_NUM; i++)
|
||||
hlua_class_const_int(gL.T, pat_match_names[i], i);
|
||||
for (i=0; i<PAT_MATCH_NUM; i++) {
|
||||
snprintf(trash.str, trash.size, "_%s", pat_match_names[i]);
|
||||
hlua_class_const_int(gL.T, trash.str, i);
|
||||
snprintf(trash.area, trash.size, "_%s", pat_match_names[i]);
|
||||
hlua_class_const_int(gL.T, trash.area, i);
|
||||
}
|
||||
|
||||
/* register constructor. */
|
||||
@ -7747,14 +7757,14 @@ void hlua_init(void)
|
||||
/* gL.Tua doesn't support '.' and '-' in the function names, replace it
|
||||
* by an underscore.
|
||||
*/
|
||||
strncpy(trash.str, sf->kw, trash.size);
|
||||
trash.str[trash.size - 1] = '\0';
|
||||
for (p = trash.str; *p; p++)
|
||||
strncpy(trash.area, sf->kw, trash.size);
|
||||
trash.area[trash.size - 1] = '\0';
|
||||
for (p = trash.area; *p; p++)
|
||||
if (*p == '.' || *p == '-' || *p == '+')
|
||||
*p = '_';
|
||||
|
||||
/* Register the function. */
|
||||
lua_pushstring(gL.T, trash.str);
|
||||
lua_pushstring(gL.T, trash.area);
|
||||
lua_pushlightuserdata(gL.T, sf);
|
||||
lua_pushcclosure(gL.T, hlua_run_sample_fetch, 1);
|
||||
lua_rawset(gL.T, -3);
|
||||
@ -7792,14 +7802,14 @@ void hlua_init(void)
|
||||
/* gL.Tua doesn't support '.' and '-' in the function names, replace it
|
||||
* by an underscore.
|
||||
*/
|
||||
strncpy(trash.str, sc->kw, trash.size);
|
||||
trash.str[trash.size - 1] = '\0';
|
||||
for (p = trash.str; *p; p++)
|
||||
strncpy(trash.area, sc->kw, trash.size);
|
||||
trash.area[trash.size - 1] = '\0';
|
||||
for (p = trash.area; *p; p++)
|
||||
if (*p == '.' || *p == '-' || *p == '+')
|
||||
*p = '_';
|
||||
|
||||
/* Register the function. */
|
||||
lua_pushstring(gL.T, trash.str);
|
||||
lua_pushstring(gL.T, trash.area);
|
||||
lua_pushlightuserdata(gL.T, sc);
|
||||
lua_pushcclosure(gL.T, hlua_run_sample_conv, 1);
|
||||
lua_rawset(gL.T, -3);
|
||||
|
@ -1204,9 +1204,9 @@ static int hlua_regex_exec(struct lua_State *L)
|
||||
lua_pushboolean(L, 0);
|
||||
return 1;
|
||||
}
|
||||
memcpy(tmp->str, str, len);
|
||||
memcpy(tmp->area, str, len);
|
||||
|
||||
lua_pushboolean(L, regex_exec2(regex, tmp->str, len));
|
||||
lua_pushboolean(L, regex_exec2(regex, tmp->area, len));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1232,9 +1232,9 @@ static int hlua_regex_match(struct lua_State *L)
|
||||
lua_pushboolean(L, 0);
|
||||
return 1;
|
||||
}
|
||||
memcpy(tmp->str, str, len);
|
||||
memcpy(tmp->area, str, len);
|
||||
|
||||
ret = regex_exec_match2(regex, tmp->str, len, 20, pmatch, 0);
|
||||
ret = regex_exec_match2(regex, tmp->area, len, 20, pmatch, 0);
|
||||
lua_pushboolean(L, ret);
|
||||
lua_newtable(L);
|
||||
if (ret) {
|
||||
|
@ -126,12 +126,12 @@ static inline struct ist hpack_alloc_string(struct chunk *store, int idx, struct
|
||||
if (unlikely(!out.ptr))
|
||||
return out;
|
||||
|
||||
if (unlikely(store->len + out.len > store->size)) {
|
||||
if (unlikely(store->data + out.len > store->size)) {
|
||||
out.ptr = NULL;
|
||||
return out;
|
||||
}
|
||||
|
||||
store->len += out.len;
|
||||
store->data += out.len;
|
||||
memcpy(out.ptr, in.ptr, out.len);
|
||||
return out;
|
||||
}
|
||||
@ -277,7 +277,8 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
nlen = huff_dec((const uint8_t *)name.ptr, name.len, ntrash, tmp->size - tmp->len);
|
||||
nlen = huff_dec((const uint8_t *)name.ptr, name.len, ntrash,
|
||||
tmp->size - tmp->data);
|
||||
if (nlen == (uint32_t)-1) {
|
||||
hpack_debug_printf("2: can't decode huffman.\n");
|
||||
ret = -HPACK_ERR_HUFFMAN;
|
||||
@ -285,7 +286,7 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len,
|
||||
}
|
||||
hpack_debug_printf(" [name huff %d->%d] ", (int)name.len, (int)nlen);
|
||||
|
||||
tmp->len += nlen; // make room for the value
|
||||
tmp->data += nlen; // make room for the value
|
||||
name = ist2(ntrash, nlen);
|
||||
}
|
||||
|
||||
@ -317,7 +318,8 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
vlen = huff_dec((const uint8_t *)value.ptr, value.len, vtrash, tmp->size - tmp->len);
|
||||
vlen = huff_dec((const uint8_t *)value.ptr, value.len, vtrash,
|
||||
tmp->size - tmp->data);
|
||||
if (vlen == (uint32_t)-1) {
|
||||
hpack_debug_printf("3: can't decode huffman.\n");
|
||||
ret = -HPACK_ERR_HUFFMAN;
|
||||
@ -325,7 +327,7 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len,
|
||||
}
|
||||
hpack_debug_printf(" [value huff %d->%d] ", (int)value.len, (int)vlen);
|
||||
|
||||
tmp->len += vlen; // make room for the value
|
||||
tmp->data += vlen; // make room for the value
|
||||
value = ist2(vtrash, vlen);
|
||||
}
|
||||
|
||||
@ -386,15 +388,17 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
vlen = huff_dec((const uint8_t *)value.ptr, value.len, vtrash, tmp->size - tmp->len);
|
||||
vlen = huff_dec((const uint8_t *)value.ptr, value.len, vtrash,
|
||||
tmp->size - tmp->data);
|
||||
if (vlen == (uint32_t)-1) {
|
||||
hpack_debug_printf("##ERR@%d## can't decode huffman : ilen=%d osize=%d\n",
|
||||
__LINE__, (int)value.len, (int)(tmp->size - tmp->len));
|
||||
__LINE__, (int)value.len,
|
||||
(int)(tmp->size - tmp->data));
|
||||
hpack_debug_hexdump(stderr, "[HUFFMAN] ", value.ptr, 0, value.len);
|
||||
ret = -HPACK_ERR_HUFFMAN;
|
||||
goto leave;
|
||||
}
|
||||
tmp->len += vlen; // make room for the value
|
||||
tmp->data += vlen; // make room for the value
|
||||
value = ist2(vtrash, vlen);
|
||||
}
|
||||
|
||||
@ -436,10 +440,11 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len,
|
||||
}
|
||||
|
||||
hpack_debug_printf("\e[1;34m%s\e[0m: ",
|
||||
name.ptr ? istpad(trash.str, name).ptr : h2_phdr_to_str(name.len));
|
||||
name.ptr ? istpad(trash.area, name).ptr : h2_phdr_to_str(name.len));
|
||||
|
||||
hpack_debug_printf("\e[1;35m%s\e[0m [mustidx=%d, used=%d] [n=(%p,%d) v=(%p,%d)]\n",
|
||||
istpad(trash.str, value).ptr, must_index, dht->used,
|
||||
istpad(trash.area, value).ptr, must_index,
|
||||
dht->used,
|
||||
name.ptr, (int)name.len, value.ptr, (int)value.len);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ static inline int hpack_encode_len(char *out, int pos, int len)
|
||||
*/
|
||||
int hpack_encode_header(struct chunk *out, const struct ist n, const struct ist v)
|
||||
{
|
||||
int len = out->len;
|
||||
int len = out->data;
|
||||
int size = out->size;
|
||||
|
||||
if (len >= size)
|
||||
@ -89,28 +89,28 @@ int hpack_encode_header(struct chunk *out, const struct ist n, const struct ist
|
||||
* compiler factor out the common sizes.
|
||||
*/
|
||||
if (isteq(n, ist("date")))
|
||||
out->str[len++] = 0x61; // literal with indexing -- name="date" (idx 33)
|
||||
out->area[len++] = 0x61; // literal with indexing -- name="date" (idx 33)
|
||||
else if (isteq(n, ist("etag")))
|
||||
out->str[len++] = 0x62; // literal with indexing -- name="etag" (idx 34)
|
||||
out->area[len++] = 0x62; // literal with indexing -- name="etag" (idx 34)
|
||||
else if (isteq(n, ist("server")))
|
||||
out->str[len++] = 0x76; // literal with indexing -- name="server" (idx 54)
|
||||
out->area[len++] = 0x76; // literal with indexing -- name="server" (idx 54)
|
||||
else if (isteq(n, ist("location")))
|
||||
out->str[len++] = 0x6e; // literal with indexing -- name="location" (idx 46)
|
||||
out->area[len++] = 0x6e; // literal with indexing -- name="location" (idx 46)
|
||||
else if (isteq(n, ist("content-type")))
|
||||
out->str[len++] = 0x5f; // literal with indexing -- name="content-type" (idx 31)
|
||||
out->area[len++] = 0x5f; // literal with indexing -- name="content-type" (idx 31)
|
||||
else if (isteq(n, ist("last-modified")))
|
||||
out->str[len++] = 0x6c; // literal with indexing -- name="last-modified" (idx 44)
|
||||
out->area[len++] = 0x6c; // literal with indexing -- name="last-modified" (idx 44)
|
||||
else if (isteq(n, ist("accept-ranges")))
|
||||
out->str[len++] = 0x51; // literal with indexing -- name="accept-ranges" (idx 17)
|
||||
out->area[len++] = 0x51; // literal with indexing -- name="accept-ranges" (idx 17)
|
||||
else if (isteq(n, ist("cache-control")))
|
||||
out->str[len++] = 0x58; // literal with indexing -- name="cache-control" (idx 24)
|
||||
out->area[len++] = 0x58; // literal with indexing -- name="cache-control" (idx 24)
|
||||
else if (isteq(n, ist("content-length")))
|
||||
out->str[len++] = 0x5c; // literal with indexing -- name="content-length" (idx 28)
|
||||
out->area[len++] = 0x5c; // literal with indexing -- name="content-length" (idx 28)
|
||||
else if (len_to_bytes(n.len) && len + len_to_bytes(n.len) + n.len <= size) {
|
||||
out->str[len++] = 0x00; /* literal without indexing -- new name */
|
||||
out->area[len++] = 0x00; /* literal without indexing -- new name */
|
||||
|
||||
len = hpack_encode_len(out->str, len, n.len);
|
||||
memcpy(out->str + len, n.ptr, n.len);
|
||||
len = hpack_encode_len(out->area, len, n.len);
|
||||
memcpy(out->area + len, n.ptr, n.len);
|
||||
len += n.len;
|
||||
}
|
||||
else {
|
||||
@ -124,10 +124,10 @@ int hpack_encode_header(struct chunk *out, const struct ist n, const struct ist
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = hpack_encode_len(out->str, len, v.len);
|
||||
memcpy(out->str + len, v.ptr, v.len);
|
||||
len = hpack_encode_len(out->area, len, v.len);
|
||||
memcpy(out->area + len, v.ptr, v.len);
|
||||
len += v.len;
|
||||
|
||||
out->len = len;
|
||||
out->data = len;
|
||||
return 1;
|
||||
}
|
||||
|
94
src/log.c
94
src/log.c
@ -57,15 +57,15 @@ static const struct log_fmt log_formats[LOG_FORMATS] = {
|
||||
[LOG_FORMAT_RFC3164] = {
|
||||
.name = "rfc3164",
|
||||
.pid = {
|
||||
.sep1 = { .str = "[", .len = 1 },
|
||||
.sep2 = { .str = "]: ", .len = 3 }
|
||||
.sep1 = { .area = "[", .data = 1 },
|
||||
.sep2 = { .area = "]: ", .data = 3 }
|
||||
}
|
||||
},
|
||||
[LOG_FORMAT_RFC5424] = {
|
||||
.name = "rfc5424",
|
||||
.pid = {
|
||||
.sep1 = { .str = " ", .len = 1 },
|
||||
.sep2 = { .str = " - ", .len = 3 }
|
||||
.sep1 = { .area = " ", .data = 1 },
|
||||
.sep2 = { .area = " - ", .data = 3 }
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1013,8 +1013,8 @@ static char *lf_encode_chunk(char *start, char *stop,
|
||||
|
||||
if (node->options & LOG_OPT_ESC) {
|
||||
if (start < stop) {
|
||||
str = chunk->str;
|
||||
end = chunk->str + chunk->len;
|
||||
str = chunk->area;
|
||||
end = chunk->area + chunk->data;
|
||||
|
||||
stop--; /* reserve one byte for the final '\0' */
|
||||
while (start < stop && str < end) {
|
||||
@ -1158,7 +1158,7 @@ static char *update_log_hdr(const time_t time)
|
||||
{
|
||||
static THREAD_LOCAL long tvsec;
|
||||
static THREAD_LOCAL char *dataptr = NULL; /* backup of last end of header, NULL first time */
|
||||
static THREAD_LOCAL struct chunk host = { NULL, 0, 0 };
|
||||
static THREAD_LOCAL struct chunk host = { };
|
||||
static THREAD_LOCAL int sep = 0;
|
||||
|
||||
if (unlikely(time != tvsec || dataptr == NULL)) {
|
||||
@ -1169,17 +1169,17 @@ static char *update_log_hdr(const time_t time)
|
||||
tvsec = time;
|
||||
get_localtime(tvsec, &tm);
|
||||
|
||||
if (unlikely(global.log_send_hostname != host.str)) {
|
||||
host.str = global.log_send_hostname;
|
||||
host.len = host.str ? strlen(host.str) : 0;
|
||||
sep = host.len ? 1 : 0;
|
||||
if (unlikely(global.log_send_hostname != host.area)) {
|
||||
host.area = global.log_send_hostname;
|
||||
host.data = host.area ? strlen(host.area) : 0;
|
||||
sep = host.data ? 1 : 0;
|
||||
}
|
||||
|
||||
hdr_len = snprintf(logheader, global.max_syslog_len,
|
||||
"<<<<>%s %2d %02d:%02d:%02d %.*s%*s",
|
||||
monthname[tm.tm_mon],
|
||||
tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
|
||||
host.len, host.str, sep, "");
|
||||
(int)host.data, host.area, sep, "");
|
||||
/* WARNING: depending upon implementations, snprintf may return
|
||||
* either -1 or the number of bytes that would be needed to store
|
||||
* the total message. In both cases, we must adjust it.
|
||||
@ -1297,7 +1297,7 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
|
||||
if (!LIST_ISEMPTY(&p->logsrvs)) {
|
||||
logsrvs = &p->logsrvs;
|
||||
}
|
||||
if (p->log_tag.str) {
|
||||
if (p->log_tag.area) {
|
||||
tag = &p->log_tag;
|
||||
}
|
||||
}
|
||||
@ -1401,7 +1401,7 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
|
||||
maxlen = logsrv->maxlen - hdr_max;
|
||||
|
||||
/* tag */
|
||||
tag_max = tag->len;
|
||||
tag_max = tag->data;
|
||||
if (unlikely(tag_max >= maxlen)) {
|
||||
tag_max = maxlen - 1;
|
||||
sd_max = 0;
|
||||
@ -1411,18 +1411,18 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
|
||||
maxlen -= tag_max;
|
||||
|
||||
/* first pid separator */
|
||||
pid_sep1_max = log_formats[logsrv->format].pid.sep1.len;
|
||||
pid_sep1_max = log_formats[logsrv->format].pid.sep1.data;
|
||||
if (unlikely(pid_sep1_max >= maxlen)) {
|
||||
pid_sep1_max = maxlen - 1;
|
||||
sd_max = 0;
|
||||
goto send;
|
||||
}
|
||||
|
||||
pid_sep1 = log_formats[logsrv->format].pid.sep1.str;
|
||||
pid_sep1 = log_formats[logsrv->format].pid.sep1.area;
|
||||
maxlen -= pid_sep1_max;
|
||||
|
||||
/* pid */
|
||||
pid_max = pid.len;
|
||||
pid_max = pid.data;
|
||||
if (unlikely(pid_max >= maxlen)) {
|
||||
pid_max = maxlen - 1;
|
||||
sd_max = 0;
|
||||
@ -1432,14 +1432,14 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
|
||||
maxlen -= pid_max;
|
||||
|
||||
/* second pid separator */
|
||||
pid_sep2_max = log_formats[logsrv->format].pid.sep2.len;
|
||||
pid_sep2_max = log_formats[logsrv->format].pid.sep2.data;
|
||||
if (unlikely(pid_sep2_max >= maxlen)) {
|
||||
pid_sep2_max = maxlen - 1;
|
||||
sd_max = 0;
|
||||
goto send;
|
||||
}
|
||||
|
||||
pid_sep2 = log_formats[logsrv->format].pid.sep2.str;
|
||||
pid_sep2 = log_formats[logsrv->format].pid.sep2.area;
|
||||
maxlen -= pid_sep2_max;
|
||||
|
||||
/* structured-data */
|
||||
@ -1452,11 +1452,11 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
|
||||
send:
|
||||
iovec[0].iov_base = hdr_ptr;
|
||||
iovec[0].iov_len = hdr_max;
|
||||
iovec[1].iov_base = tag->str;
|
||||
iovec[1].iov_base = tag->area;
|
||||
iovec[1].iov_len = tag_max;
|
||||
iovec[2].iov_base = pid_sep1;
|
||||
iovec[2].iov_len = pid_sep1_max;
|
||||
iovec[3].iov_base = pid.str;
|
||||
iovec[3].iov_base = pid.area;
|
||||
iovec[3].iov_len = pid_max;
|
||||
iovec[4].iov_base = pid_sep2;
|
||||
iovec[4].iov_len = pid_sep2_max;
|
||||
@ -1606,7 +1606,7 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
struct connection *conn;
|
||||
const char *src = NULL;
|
||||
struct sample *key;
|
||||
const struct chunk empty = { NULL, 0, 0 };
|
||||
const struct chunk empty = { };
|
||||
|
||||
switch (tmp->type) {
|
||||
case LOG_FMT_SEPARATOR:
|
||||
@ -1635,7 +1635,11 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
ret = lf_encode_chunk(tmplog, dst + maxsize,
|
||||
'%', http_encode_map, key ? &key->data.u.str : &empty, tmp);
|
||||
else
|
||||
ret = lf_text_len(tmplog, key ? key->data.u.str.str : NULL, key ? key->data.u.str.len : 0, dst + maxsize - tmplog, tmp);
|
||||
ret = lf_text_len(tmplog,
|
||||
key ? key->data.u.str.area : NULL,
|
||||
key ? key->data.u.str.data : 0,
|
||||
dst + maxsize - tmplog,
|
||||
tmp);
|
||||
if (ret == 0)
|
||||
goto out;
|
||||
tmplog = ret;
|
||||
@ -2278,11 +2282,11 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
spc++;
|
||||
|
||||
if (!txn || !txn->uri || nspaces == 0) {
|
||||
chunk.str = "<BADREQ>";
|
||||
chunk.len = strlen("<BADREQ>");
|
||||
chunk.area = "<BADREQ>";
|
||||
chunk.data = strlen("<BADREQ>");
|
||||
} else {
|
||||
chunk.str = uri;
|
||||
chunk.len = spc - uri;
|
||||
chunk.area = uri;
|
||||
chunk.data = spc - uri;
|
||||
}
|
||||
|
||||
ret = lf_encode_chunk(tmplog, dst + maxsize, '#', url_encode_map, &chunk, tmp);
|
||||
@ -2301,8 +2305,8 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
LOGCHAR('"');
|
||||
|
||||
if (!txn || !txn->uri) {
|
||||
chunk.str = "<BADREQ>";
|
||||
chunk.len = strlen("<BADREQ>");
|
||||
chunk.area = "<BADREQ>";
|
||||
chunk.data = strlen("<BADREQ>");
|
||||
} else {
|
||||
uri = txn->uri;
|
||||
end = uri + strlen(uri);
|
||||
@ -2315,8 +2319,8 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
while (uri < end && !HTTP_IS_SPHT(*uri))
|
||||
uri++;
|
||||
|
||||
chunk.str = qmark;
|
||||
chunk.len = uri - qmark;
|
||||
chunk.area = qmark;
|
||||
chunk.data = uri - qmark;
|
||||
}
|
||||
|
||||
ret = lf_encode_chunk(tmplog, dst + maxsize, '#', url_encode_map, &chunk, tmp);
|
||||
@ -2352,11 +2356,11 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
spc++;
|
||||
|
||||
if (!txn || !txn->uri || nspaces == 0) {
|
||||
chunk.str = "<BADREQ>";
|
||||
chunk.len = strlen("<BADREQ>");
|
||||
chunk.area = "<BADREQ>";
|
||||
chunk.data = strlen("<BADREQ>");
|
||||
} else {
|
||||
chunk.str = uri;
|
||||
chunk.len = spc - uri;
|
||||
chunk.area = uri;
|
||||
chunk.data = spc - uri;
|
||||
}
|
||||
|
||||
ret = lf_encode_chunk(tmplog, dst + maxsize, '#', url_encode_map, &chunk, tmp);
|
||||
@ -2382,11 +2386,11 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
spc++;
|
||||
|
||||
if (spc == end) { // odd case, we have txn->uri, but we only got a verb
|
||||
chunk.str = "<BADREQ>";
|
||||
chunk.len = strlen("<BADREQ>");
|
||||
chunk.area = "<BADREQ>";
|
||||
chunk.data = strlen("<BADREQ>");
|
||||
} else {
|
||||
chunk.str = uri;
|
||||
chunk.len = spc - uri;
|
||||
chunk.area = uri;
|
||||
chunk.data = spc - uri;
|
||||
}
|
||||
|
||||
ret = lf_encode_chunk(tmplog, dst + maxsize, '#', url_encode_map, &chunk, tmp);
|
||||
@ -2424,14 +2428,14 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
uri++;
|
||||
|
||||
if (!txn || !txn->uri || nspaces == 0) {
|
||||
chunk.str = "<BADREQ>";
|
||||
chunk.len = strlen("<BADREQ>");
|
||||
chunk.area = "<BADREQ>";
|
||||
chunk.data = strlen("<BADREQ>");
|
||||
} else if (uri == end) {
|
||||
chunk.str = "HTTP/0.9";
|
||||
chunk.len = strlen("HTTP/0.9");
|
||||
chunk.area = "HTTP/0.9";
|
||||
chunk.data = strlen("HTTP/0.9");
|
||||
} else {
|
||||
chunk.str = uri;
|
||||
chunk.len = end - uri;
|
||||
chunk.area = uri;
|
||||
chunk.data = end - uri;
|
||||
}
|
||||
|
||||
ret = lf_encode_chunk(tmplog, dst + maxsize, '#', url_encode_map, &chunk, tmp);
|
||||
|
36
src/map.c
36
src/map.c
@ -57,9 +57,9 @@ int map_parse_ip(const char *text, struct sample_data *data)
|
||||
*/
|
||||
int map_parse_str(const char *text, struct sample_data *data)
|
||||
{
|
||||
data->u.str.str = (char *)text;
|
||||
data->u.str.len = strlen(text);
|
||||
data->u.str.size = data->u.str.len + 1;
|
||||
data->u.str.area = (char *)text;
|
||||
data->u.str.data = strlen(text);
|
||||
data->u.str.size = data->u.str.data + 1;
|
||||
data->type = SMP_T_STR;
|
||||
return 1;
|
||||
}
|
||||
@ -138,7 +138,7 @@ int sample_load_map(struct arg *arg, struct sample_conv *conv,
|
||||
}
|
||||
|
||||
/* Load map. */
|
||||
if (!pattern_read_from_file(&desc->pat, PAT_REF_MAP, arg[0].data.str.str, PAT_MF_NO_DNS,
|
||||
if (!pattern_read_from_file(&desc->pat, PAT_REF_MAP, arg[0].data.str.area, PAT_MF_NO_DNS,
|
||||
1, err, file, line))
|
||||
return 0;
|
||||
|
||||
@ -147,8 +147,9 @@ int sample_load_map(struct arg *arg, struct sample_conv *conv,
|
||||
*/
|
||||
if (desc->conv->out_type == SMP_T_ADDR) {
|
||||
struct sample_data data;
|
||||
if (!map_parse_ip(arg[1].data.str.str, &data)) {
|
||||
memprintf(err, "map: cannot parse default ip <%s>.", arg[1].data.str.str);
|
||||
if (!map_parse_ip(arg[1].data.str.area, &data)) {
|
||||
memprintf(err, "map: cannot parse default ip <%s>.",
|
||||
arg[1].data.str.area);
|
||||
return 0;
|
||||
}
|
||||
if (data.type == SMP_T_IPV4) {
|
||||
@ -185,10 +186,11 @@ static int sample_conv_map(const struct arg *arg_p, struct sample *smp, void *pr
|
||||
/* In the regm case, merge the sample with the input. */
|
||||
if ((long)private == PAT_MATCH_REGM) {
|
||||
str = get_trash_chunk();
|
||||
str->len = exp_replace(str->str, str->size, smp->data.u.str.str,
|
||||
pat->data->u.str.str,
|
||||
str->data = exp_replace(str->area, str->size,
|
||||
smp->data.u.str.area,
|
||||
pat->data->u.str.area,
|
||||
(regmatch_t *)smp->ctx.a[0]);
|
||||
if (str->len == -1)
|
||||
if (str->data == -1)
|
||||
return 0;
|
||||
smp->data.u.str = *str;
|
||||
return 1;
|
||||
@ -463,8 +465,8 @@ static int cli_io_handler_map_lookup(struct appctx *appctx)
|
||||
/* execute pattern matching */
|
||||
sample.data.type = SMP_T_STR;
|
||||
sample.flags = SMP_F_CONST;
|
||||
sample.data.u.str.len = appctx->ctx.map.chunk.len;
|
||||
sample.data.u.str.str = appctx->ctx.map.chunk.str;
|
||||
sample.data.u.str.data = appctx->ctx.map.chunk.data;
|
||||
sample.data.u.str.area = appctx->ctx.map.chunk.area;
|
||||
|
||||
if (appctx->ctx.map.expr->pat_head->match &&
|
||||
sample_convert(&sample, appctx->ctx.map.expr->pat_head->expect_type))
|
||||
@ -560,8 +562,8 @@ static int cli_io_handler_map_lookup(struct appctx *appctx)
|
||||
|
||||
static void cli_release_mlook(struct appctx *appctx)
|
||||
{
|
||||
free(appctx->ctx.map.chunk.str);
|
||||
appctx->ctx.map.chunk.str = NULL;
|
||||
free(appctx->ctx.map.chunk.area);
|
||||
appctx->ctx.map.chunk.area = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -607,10 +609,10 @@ static int cli_parse_get_map(char **args, char *payload, struct appctx *appctx,
|
||||
* it may be used over multiple iterations. It's released
|
||||
* at the end and upon abort anyway.
|
||||
*/
|
||||
appctx->ctx.map.chunk.len = strlen(args[3]);
|
||||
appctx->ctx.map.chunk.size = appctx->ctx.map.chunk.len + 1;
|
||||
appctx->ctx.map.chunk.str = strdup(args[3]);
|
||||
if (!appctx->ctx.map.chunk.str) {
|
||||
appctx->ctx.map.chunk.data = strlen(args[3]);
|
||||
appctx->ctx.map.chunk.size = appctx->ctx.map.chunk.data + 1;
|
||||
appctx->ctx.map.chunk.area = strdup(args[3]);
|
||||
if (!appctx->ctx.map.chunk.area) {
|
||||
appctx->ctx.cli.severity = LOG_ERR;
|
||||
appctx->ctx.cli.msg = "Out of memory error.\n";
|
||||
appctx->st0 = CLI_ST_PRINT;
|
||||
|
@ -394,7 +394,7 @@ void dump_pools_to_trash()
|
||||
void dump_pools(void)
|
||||
{
|
||||
dump_pools_to_trash();
|
||||
qfprintf(stderr, "%s", trash.str);
|
||||
qfprintf(stderr, "%s", trash.area);
|
||||
}
|
||||
|
||||
/* This function returns the total number of failed pool allocations */
|
||||
|
70
src/mux_h2.c
70
src/mux_h2.c
@ -727,8 +727,8 @@ static int h2c_snd_settings(struct h2c *h2c)
|
||||
chunk_memcat(&buf, str, 6);
|
||||
}
|
||||
|
||||
h2_set_frame_size(buf.str, buf.len - 9);
|
||||
ret = b_istput(res, ist2(buf.str, buf.len));
|
||||
h2_set_frame_size(buf.area, buf.data - 9);
|
||||
ret = b_istput(res, ist2(buf.area, buf.data));
|
||||
if (unlikely(ret <= 0)) {
|
||||
if (!ret) {
|
||||
h2c->flags |= H2_CF_MUX_MFULL;
|
||||
@ -2643,9 +2643,9 @@ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count,
|
||||
h2c_error(h2c, H2_ERR_INTERNAL_ERROR);
|
||||
goto fail;
|
||||
}
|
||||
memcpy(copy->str, b_head(&h2c->dbuf), wrap);
|
||||
memcpy(copy->str + wrap, b_orig(&h2c->dbuf), h2c->dfl - wrap);
|
||||
hdrs = (uint8_t *)copy->str;
|
||||
memcpy(copy->area, b_head(&h2c->dbuf), wrap);
|
||||
memcpy(copy->area + wrap, b_orig(&h2c->dbuf), h2c->dfl - wrap);
|
||||
hdrs = (uint8_t *) copy->area;
|
||||
}
|
||||
|
||||
/* The padlen is the first byte before data, and the padding appears
|
||||
@ -2699,7 +2699,7 @@ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count,
|
||||
/* it doesn't fit and the buffer is fragmented,
|
||||
* so let's defragment it and try again.
|
||||
*/
|
||||
b_slow_realign(buf, trash.str, 0);
|
||||
b_slow_realign(buf, trash.area, 0);
|
||||
}
|
||||
|
||||
try = b_contig_space(buf);
|
||||
@ -2994,14 +2994,14 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, const struct buffer *bu
|
||||
chunk_reset(&outbuf);
|
||||
|
||||
while (1) {
|
||||
outbuf.str = b_tail(&h2c->mbuf);
|
||||
outbuf.area = b_tail(&h2c->mbuf);
|
||||
outbuf.size = b_contig_space(&h2c->mbuf);
|
||||
outbuf.len = 0;
|
||||
outbuf.data = 0;
|
||||
|
||||
if (outbuf.size >= 9 || !b_space_wraps(&h2c->mbuf))
|
||||
break;
|
||||
realign_again:
|
||||
b_slow_realign(&h2c->mbuf, trash.str, b_data(&h2c->mbuf));
|
||||
b_slow_realign(&h2c->mbuf, trash.area, b_data(&h2c->mbuf));
|
||||
}
|
||||
|
||||
if (outbuf.size < 9) {
|
||||
@ -3012,28 +3012,28 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, const struct buffer *bu
|
||||
}
|
||||
|
||||
/* len: 0x000000 (fill later), type: 1(HEADERS), flags: ENDH=4 */
|
||||
memcpy(outbuf.str, "\x00\x00\x00\x01\x04", 5);
|
||||
write_n32(outbuf.str + 5, h2s->id); // 4 bytes
|
||||
outbuf.len = 9;
|
||||
memcpy(outbuf.area, "\x00\x00\x00\x01\x04", 5);
|
||||
write_n32(outbuf.area + 5, h2s->id); // 4 bytes
|
||||
outbuf.data = 9;
|
||||
|
||||
/* encode status, which necessarily is the first one */
|
||||
if (outbuf.len < outbuf.size && h1m->status == 200)
|
||||
outbuf.str[outbuf.len++] = 0x88; // indexed field : idx[08]=(":status", "200")
|
||||
else if (outbuf.len < outbuf.size && h1m->status == 304)
|
||||
outbuf.str[outbuf.len++] = 0x8b; // indexed field : idx[11]=(":status", "304")
|
||||
if (outbuf.data < outbuf.size && h1m->status == 200)
|
||||
outbuf.area[outbuf.data++] = 0x88; // indexed field : idx[08]=(":status", "200")
|
||||
else if (outbuf.data < outbuf.size && h1m->status == 304)
|
||||
outbuf.area[outbuf.data++] = 0x8b; // indexed field : idx[11]=(":status", "304")
|
||||
else if (unlikely(list[0].v.len != 3)) {
|
||||
/* this is an unparsable response */
|
||||
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
else if (unlikely(outbuf.len + 2 + 3 <= outbuf.size)) {
|
||||
else if (unlikely(outbuf.data + 2 + 3 <= outbuf.size)) {
|
||||
/* basic encoding of the status code */
|
||||
outbuf.str[outbuf.len++] = 0x48; // indexed name -- name=":status" (idx 8)
|
||||
outbuf.str[outbuf.len++] = 0x03; // 3 bytes status
|
||||
outbuf.str[outbuf.len++] = list[0].v.ptr[0];
|
||||
outbuf.str[outbuf.len++] = list[0].v.ptr[1];
|
||||
outbuf.str[outbuf.len++] = list[0].v.ptr[2];
|
||||
outbuf.area[outbuf.data++] = 0x48; // indexed name -- name=":status" (idx 8)
|
||||
outbuf.area[outbuf.data++] = 0x03; // 3 bytes status
|
||||
outbuf.area[outbuf.data++] = list[0].v.ptr[0];
|
||||
outbuf.area[outbuf.data++] = list[0].v.ptr[1];
|
||||
outbuf.area[outbuf.data++] = list[0].v.ptr[2];
|
||||
}
|
||||
else {
|
||||
if (b_space_wraps(&h2c->mbuf))
|
||||
@ -3075,16 +3075,16 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, const struct buffer *bu
|
||||
es_now = 1;
|
||||
|
||||
/* update the frame's size */
|
||||
h2_set_frame_size(outbuf.str, outbuf.len - 9);
|
||||
h2_set_frame_size(outbuf.area, outbuf.data - 9);
|
||||
|
||||
if (es_now)
|
||||
outbuf.str[4] |= H2_F_HEADERS_END_STREAM;
|
||||
outbuf.area[4] |= H2_F_HEADERS_END_STREAM;
|
||||
|
||||
/* consume incoming H1 response */
|
||||
max -= ret;
|
||||
|
||||
/* commit the H2 response */
|
||||
b_add(&h2c->mbuf, outbuf.len);
|
||||
b_add(&h2c->mbuf, outbuf.data);
|
||||
h2s->flags |= H2_SF_HEADERS_SENT;
|
||||
|
||||
/* for now we don't implemented CONTINUATION, so we wait for a
|
||||
@ -3151,14 +3151,14 @@ static size_t h2s_frt_make_resp_data(struct h2s *h2s, const struct buffer *buf,
|
||||
chunk_reset(&outbuf);
|
||||
|
||||
while (1) {
|
||||
outbuf.str = b_tail(&h2c->mbuf);
|
||||
outbuf.area = b_tail(&h2c->mbuf);
|
||||
outbuf.size = b_contig_space(&h2c->mbuf);
|
||||
outbuf.len = 0;
|
||||
outbuf.data = 0;
|
||||
|
||||
if (outbuf.size >= 9 || !b_space_wraps(&h2c->mbuf))
|
||||
break;
|
||||
realign_again:
|
||||
b_slow_realign(&h2c->mbuf, trash.str, b_data(&h2c->mbuf));
|
||||
b_slow_realign(&h2c->mbuf, trash.area, b_data(&h2c->mbuf));
|
||||
}
|
||||
|
||||
if (outbuf.size < 9) {
|
||||
@ -3168,9 +3168,9 @@ static size_t h2s_frt_make_resp_data(struct h2s *h2s, const struct buffer *buf,
|
||||
}
|
||||
|
||||
/* len: 0x000000 (fill later), type: 0(DATA), flags: none=0 */
|
||||
memcpy(outbuf.str, "\x00\x00\x00\x00\x00", 5);
|
||||
write_n32(outbuf.str + 5, h2s->id); // 4 bytes
|
||||
outbuf.len = 9;
|
||||
memcpy(outbuf.area, "\x00\x00\x00\x00\x00", 5);
|
||||
write_n32(outbuf.area + 5, h2s->id); // 4 bytes
|
||||
outbuf.data = 9;
|
||||
|
||||
switch (h1m->flags & (H1_MF_CLEN|H1_MF_CHNK)) {
|
||||
case 0: /* no content length, read till SHUTW */
|
||||
@ -3301,9 +3301,9 @@ static size_t h2s_frt_make_resp_data(struct h2s *h2s, const struct buffer *buf,
|
||||
}
|
||||
|
||||
/* now let's copy this this into the output buffer */
|
||||
memcpy(outbuf.str + 9, blk1, len1);
|
||||
memcpy(outbuf.area + 9, blk1, len1);
|
||||
if (len2)
|
||||
memcpy(outbuf.str + 9 + len1, blk2, len2);
|
||||
memcpy(outbuf.area + 9 + len1, blk2, len2);
|
||||
|
||||
send_empty:
|
||||
/* we may need to add END_STREAM */
|
||||
@ -3323,10 +3323,10 @@ static size_t h2s_frt_make_resp_data(struct h2s *h2s, const struct buffer *buf,
|
||||
es_now = 1;
|
||||
|
||||
/* update the frame's size */
|
||||
h2_set_frame_size(outbuf.str, size);
|
||||
h2_set_frame_size(outbuf.area, size);
|
||||
|
||||
if (es_now)
|
||||
outbuf.str[4] |= H2_F_DATA_END_STREAM;
|
||||
outbuf.area[4] |= H2_F_DATA_END_STREAM;
|
||||
|
||||
/* commit the H2 response */
|
||||
b_add(&h2c->mbuf, size + 9);
|
||||
|
@ -26,7 +26,7 @@ static int open_named_namespace(const char *ns_name)
|
||||
{
|
||||
if (chunk_printf(&trash, "/var/run/netns/%s", ns_name) < 0)
|
||||
return -1;
|
||||
return open(trash.str, O_RDONLY);
|
||||
return open(trash.area, O_RDONLY);
|
||||
}
|
||||
|
||||
static int default_namespace = -1;
|
||||
@ -35,7 +35,7 @@ static int init_default_namespace()
|
||||
{
|
||||
if (chunk_printf(&trash, "/proc/%d/ns/net", getpid()) < 0)
|
||||
return -1;
|
||||
default_namespace = open(trash.str, O_RDONLY);
|
||||
default_namespace = open(trash.area, O_RDONLY);
|
||||
return default_namespace;
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ int pat_parse_bin(const char *text, struct pattern *pattern, int mflags, char **
|
||||
pattern->type = SMP_T_BIN;
|
||||
trash = get_trash_chunk();
|
||||
pattern->len = trash->size;
|
||||
pattern->ptr.str = trash->str;
|
||||
pattern->ptr.str = trash->area;
|
||||
return !!parse_binary(text, &pattern->ptr.str, &pattern->len, err);
|
||||
}
|
||||
|
||||
@ -463,12 +463,12 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
|
||||
/* Lookup a string in the expression's pattern tree. */
|
||||
if (!eb_is_empty(&expr->pattern_tree)) {
|
||||
/* we may have to force a trailing zero on the test pattern */
|
||||
prev = smp->data.u.str.str[smp->data.u.str.len];
|
||||
prev = smp->data.u.str.area[smp->data.u.str.data];
|
||||
if (prev)
|
||||
smp->data.u.str.str[smp->data.u.str.len] = '\0';
|
||||
node = ebst_lookup(&expr->pattern_tree, smp->data.u.str.str);
|
||||
smp->data.u.str.area[smp->data.u.str.data] = '\0';
|
||||
node = ebst_lookup(&expr->pattern_tree, smp->data.u.str.area);
|
||||
if (prev)
|
||||
smp->data.u.str.str[smp->data.u.str.len] = prev;
|
||||
smp->data.u.str.area[smp->data.u.str.data] = prev;
|
||||
|
||||
if (node) {
|
||||
if (fill) {
|
||||
@ -488,7 +488,7 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
HA_SPIN_LOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (!lru) {
|
||||
HA_SPIN_UNLOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
@ -504,12 +504,12 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len != smp->data.u.str.len)
|
||||
if (pattern->len != smp->data.u.str.data)
|
||||
continue;
|
||||
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.str, smp->data.u.str.len) == 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.u.str.str, smp->data.u.str.len) == 0)) {
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.area, smp->data.u.str.data) == 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.u.str.area, smp->data.u.str.data) == 0)) {
|
||||
ret = pattern;
|
||||
break;
|
||||
}
|
||||
@ -535,7 +535,7 @@ struct pattern *pat_match_bin(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
HA_SPIN_LOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (!lru) {
|
||||
HA_SPIN_UNLOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
@ -550,10 +550,10 @@ struct pattern *pat_match_bin(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len != smp->data.u.str.len)
|
||||
if (pattern->len != smp->data.u.str.data)
|
||||
continue;
|
||||
|
||||
if (memcmp(pattern->ptr.str, smp->data.u.str.str, smp->data.u.str.len) == 0) {
|
||||
if (memcmp(pattern->ptr.str, smp->data.u.str.area, smp->data.u.str.data) == 0) {
|
||||
ret = pattern;
|
||||
break;
|
||||
}
|
||||
@ -580,7 +580,7 @@ struct pattern *pat_match_regm(struct sample *smp, struct pattern_expr *expr, in
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (regex_exec_match2(pattern->ptr.reg, smp->data.u.str.str, smp->data.u.str.len,
|
||||
if (regex_exec_match2(pattern->ptr.reg, smp->data.u.str.area, smp->data.u.str.data,
|
||||
MAX_MATCH, pmatch, 0)) {
|
||||
ret = pattern;
|
||||
smp->ctx.a[0] = pmatch;
|
||||
@ -605,7 +605,7 @@ struct pattern *pat_match_reg(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
HA_SPIN_LOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (!lru) {
|
||||
HA_SPIN_UNLOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
@ -620,7 +620,7 @@ struct pattern *pat_match_reg(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (regex_exec2(pattern->ptr.reg, smp->data.u.str.str, smp->data.u.str.len)) {
|
||||
if (regex_exec2(pattern->ptr.reg, smp->data.u.str.area, smp->data.u.str.data)) {
|
||||
ret = pattern;
|
||||
break;
|
||||
}
|
||||
@ -649,12 +649,13 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
|
||||
/* Lookup a string in the expression's pattern tree. */
|
||||
if (!eb_is_empty(&expr->pattern_tree)) {
|
||||
/* we may have to force a trailing zero on the test pattern */
|
||||
prev = smp->data.u.str.str[smp->data.u.str.len];
|
||||
prev = smp->data.u.str.area[smp->data.u.str.data];
|
||||
if (prev)
|
||||
smp->data.u.str.str[smp->data.u.str.len] = '\0';
|
||||
node = ebmb_lookup_longest(&expr->pattern_tree, smp->data.u.str.str);
|
||||
smp->data.u.str.area[smp->data.u.str.data] = '\0';
|
||||
node = ebmb_lookup_longest(&expr->pattern_tree,
|
||||
smp->data.u.str.area);
|
||||
if (prev)
|
||||
smp->data.u.str.str[smp->data.u.str.len] = prev;
|
||||
smp->data.u.str.area[smp->data.u.str.data] = prev;
|
||||
|
||||
if (node) {
|
||||
if (fill) {
|
||||
@ -674,7 +675,7 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
HA_SPIN_LOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (!lru) {
|
||||
HA_SPIN_UNLOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
@ -689,12 +690,12 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len > smp->data.u.str.len)
|
||||
if (pattern->len > smp->data.u.str.data)
|
||||
continue;
|
||||
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.str, pattern->len) != 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.u.str.str, pattern->len) != 0))
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.area, pattern->len) != 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.u.str.area, pattern->len) != 0))
|
||||
continue;
|
||||
|
||||
ret = pattern;
|
||||
@ -722,7 +723,7 @@ struct pattern *pat_match_end(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
HA_SPIN_LOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (!lru) {
|
||||
HA_SPIN_UNLOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
@ -737,12 +738,12 @@ struct pattern *pat_match_end(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len > smp->data.u.str.len)
|
||||
if (pattern->len > smp->data.u.str.data)
|
||||
continue;
|
||||
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.str + smp->data.u.str.len - pattern->len, pattern->len) != 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.u.str.str + smp->data.u.str.len - pattern->len, pattern->len) != 0))
|
||||
if ((icase && strncasecmp(pattern->ptr.str, smp->data.u.str.area + smp->data.u.str.data - pattern->len, pattern->len) != 0) ||
|
||||
(!icase && strncmp(pattern->ptr.str, smp->data.u.str.area + smp->data.u.str.data - pattern->len, pattern->len) != 0))
|
||||
continue;
|
||||
|
||||
ret = pattern;
|
||||
@ -774,7 +775,7 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
HA_SPIN_LOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
lru = lru64_get(XXH64(smp->data.u.str.str, smp->data.u.str.len, seed),
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
if (!lru) {
|
||||
HA_SPIN_UNLOCK(PATLRU_LOCK, &pat_lru_tree_lock);
|
||||
@ -789,13 +790,13 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
|
||||
if (pattern->len > smp->data.u.str.len)
|
||||
if (pattern->len > smp->data.u.str.data)
|
||||
continue;
|
||||
|
||||
end = smp->data.u.str.str + smp->data.u.str.len - pattern->len;
|
||||
end = smp->data.u.str.area + smp->data.u.str.data - pattern->len;
|
||||
icase = expr->mflags & PAT_MF_IGNORE_CASE;
|
||||
if (icase) {
|
||||
for (c = smp->data.u.str.str; c <= end; c++) {
|
||||
for (c = smp->data.u.str.area; c <= end; c++) {
|
||||
if (tolower(*c) != tolower(*pattern->ptr.str))
|
||||
continue;
|
||||
if (strncasecmp(pattern->ptr.str, c, pattern->len) == 0) {
|
||||
@ -804,7 +805,7 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (c = smp->data.u.str.str; c <= end; c++) {
|
||||
for (c = smp->data.u.str.area; c <= end; c++) {
|
||||
if (*c != *pattern->ptr.str)
|
||||
continue;
|
||||
if (strncmp(pattern->ptr.str, c, pattern->len) == 0) {
|
||||
@ -847,13 +848,13 @@ static int match_word(struct sample *smp, struct pattern *pattern, int mflags, u
|
||||
while (pl > 0 && is_delimiter(ps[pl - 1], delimiters))
|
||||
pl--;
|
||||
|
||||
if (pl > smp->data.u.str.len)
|
||||
if (pl > smp->data.u.str.data)
|
||||
return PAT_NOMATCH;
|
||||
|
||||
may_match = 1;
|
||||
icase = mflags & PAT_MF_IGNORE_CASE;
|
||||
end = smp->data.u.str.str + smp->data.u.str.len - pl;
|
||||
for (c = smp->data.u.str.str; c <= end; c++) {
|
||||
end = smp->data.u.str.area + smp->data.u.str.data - pl;
|
||||
for (c = smp->data.u.str.area; c <= end; c++) {
|
||||
if (is_delimiter(*c, delimiters)) {
|
||||
may_match = 1;
|
||||
continue;
|
||||
@ -935,8 +936,8 @@ struct pattern *pat_match_len(struct sample *smp, struct pattern_expr *expr, int
|
||||
|
||||
list_for_each_entry(lst, &expr->patterns, list) {
|
||||
pattern = &lst->pat;
|
||||
if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.u.str.len) &&
|
||||
(!pattern->val.range.max_set || smp->data.u.str.len <= pattern->val.range.max))
|
||||
if ((!pattern->val.range.min_set || pattern->val.range.min <= smp->data.u.str.data) &&
|
||||
(!pattern->val.range.max_set || smp->data.u.str.data <= pattern->val.range.max))
|
||||
return pattern;
|
||||
}
|
||||
return NULL;
|
||||
@ -2332,9 +2333,9 @@ int pat_ref_read_from_file_smp(struct pat_ref *ref, const char *filename, char *
|
||||
* followed by one value per line. The start spaces, separator spaces
|
||||
* and and spaces are stripped. Each can contain comment started by '#'
|
||||
*/
|
||||
while (fgets(trash.str, trash.size, file) != NULL) {
|
||||
while (fgets(trash.area, trash.size, file) != NULL) {
|
||||
line++;
|
||||
c = trash.str;
|
||||
c = trash.area;
|
||||
|
||||
/* ignore lines beginning with a dash */
|
||||
if (*c == '#')
|
||||
@ -2409,9 +2410,9 @@ int pat_ref_read_from_file(struct pat_ref *ref, const char *filename, char **err
|
||||
* line. If the line contains spaces, they will be part of the pattern.
|
||||
* The pattern stops at the first CR, LF or EOF encountered.
|
||||
*/
|
||||
while (fgets(trash.str, trash.size, file) != NULL) {
|
||||
while (fgets(trash.area, trash.size, file) != NULL) {
|
||||
line++;
|
||||
c = trash.str;
|
||||
c = trash.area;
|
||||
|
||||
/* ignore lines beginning with a dash */
|
||||
if (*c == '#')
|
||||
@ -2462,7 +2463,7 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags,
|
||||
"pattern loaded from file '%s' used by %s at file '%s' line %d",
|
||||
filename, refflags & PAT_REF_MAP ? "map" : "acl", file, line);
|
||||
|
||||
ref = pat_ref_new(filename, trash.str, refflags);
|
||||
ref = pat_ref_new(filename, trash.area, refflags);
|
||||
if (!ref) {
|
||||
memprintf(err, "out of memory");
|
||||
return 0;
|
||||
@ -2509,7 +2510,7 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags,
|
||||
chunk_appendf(&trash, ", by %s at file '%s' line %d",
|
||||
refflags & PAT_REF_MAP ? "map" : "acl", file, line);
|
||||
free(ref->display);
|
||||
ref->display = strdup(trash.str);
|
||||
ref->display = strdup(trash.area);
|
||||
if (!ref->display) {
|
||||
memprintf(err, "out of memory");
|
||||
return 0;
|
||||
@ -2596,11 +2597,13 @@ struct pattern *pattern_exec_match(struct pattern_head *head, struct sample *smp
|
||||
case SMP_T_STR:
|
||||
static_sample_data.type = SMP_T_STR;
|
||||
static_sample_data.u.str = *get_trash_chunk();
|
||||
static_sample_data.u.str.len = pat->data->u.str.len;
|
||||
if (static_sample_data.u.str.len >= static_sample_data.u.str.size)
|
||||
static_sample_data.u.str.len = static_sample_data.u.str.size - 1;
|
||||
memcpy(static_sample_data.u.str.str, pat->data->u.str.str, static_sample_data.u.str.len);
|
||||
static_sample_data.u.str.str[static_sample_data.u.str.len] = 0;
|
||||
static_sample_data.u.str.data = pat->data->u.str.data;
|
||||
if (static_sample_data.u.str.data >= static_sample_data.u.str.size)
|
||||
static_sample_data.u.str.data = static_sample_data.u.str.size - 1;
|
||||
memcpy(static_sample_data.u.str.area,
|
||||
pat->data->u.str.area,
|
||||
static_sample_data.u.str.data);
|
||||
static_sample_data.u.str.area[static_sample_data.u.str.data] = 0;
|
||||
case SMP_T_IPV4:
|
||||
case SMP_T_IPV6:
|
||||
case SMP_T_SINT:
|
||||
|
@ -630,8 +630,8 @@ smp_fetch_ssl_hello_sni(const struct arg *args, struct sample *smp, const char *
|
||||
|
||||
if (name_type == 0) { /* hostname */
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->data.u.str.str = (char *)data + 9;
|
||||
smp->data.u.str.len = name_len;
|
||||
smp->data.u.str.area = (char *)data + 9;
|
||||
smp->data.u.str.data = name_len;
|
||||
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
|
||||
return 1;
|
||||
}
|
||||
@ -714,8 +714,8 @@ fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, i
|
||||
}
|
||||
|
||||
/* data points to cookie value */
|
||||
smp->data.u.str.str = (char *)data;
|
||||
smp->data.u.str.len = 0;
|
||||
smp->data.u.str.area = (char *)data;
|
||||
smp->data.u.str.data = 0;
|
||||
|
||||
while (bleft > 0 && *data != '\r') {
|
||||
data++;
|
||||
@ -728,7 +728,7 @@ fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, i
|
||||
if (data[0] != '\r' || data[1] != '\n')
|
||||
goto not_cookie;
|
||||
|
||||
smp->data.u.str.len = (char *)data - smp->data.u.str.str;
|
||||
smp->data.u.str.data = (char *)data - smp->data.u.str.area;
|
||||
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
|
||||
return 1;
|
||||
|
||||
@ -750,7 +750,9 @@ smp_fetch_rdp_cookie(const struct arg *args, struct sample *smp, const char *kw,
|
||||
if (!smp->strm)
|
||||
return 0;
|
||||
|
||||
return fetch_rdp_cookie_name(smp->strm, smp, args ? args->data.str.str : NULL, args ? args->data.str.len : 0);
|
||||
return fetch_rdp_cookie_name(smp->strm, smp,
|
||||
args ? args->data.str.area : NULL,
|
||||
args ? args->data.str.data : 0);
|
||||
}
|
||||
|
||||
/* returns either 1 or 0 depending on whether an RDP cookie is found or not */
|
||||
@ -890,12 +892,13 @@ int val_payload_lv(struct arg *arg, char **err_msg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg[2].type == ARGT_STR && arg[2].data.str.len > 0) {
|
||||
if (arg[2].data.str.str[0] == '+' || arg[2].data.str.str[0] == '-')
|
||||
if (arg[2].type == ARGT_STR && arg[2].data.str.data > 0) {
|
||||
if (arg[2].data.str.area[0] == '+' || arg[2].data.str.area[0] == '-')
|
||||
relative = 1;
|
||||
str = arg[2].data.str.str;
|
||||
str = arg[2].data.str.area;
|
||||
arg[2].type = ARGT_SINT;
|
||||
arg[2].data.sint = read_int64(&str, str + arg[2].data.str.len);
|
||||
arg[2].data.sint = read_int64(&str,
|
||||
str + arg[2].data.str.data);
|
||||
if (*str != '\0') {
|
||||
memprintf(err_msg, "payload offset2 is not a number");
|
||||
return 0;
|
||||
@ -1087,7 +1090,7 @@ int val_distcc(struct arg *arg, char **err_msg)
|
||||
{
|
||||
unsigned int token;
|
||||
|
||||
if (arg[0].data.str.len != 4) {
|
||||
if (arg[0].data.str.data != 4) {
|
||||
memprintf(err_msg, "token name must be exactly 4 characters");
|
||||
return 0;
|
||||
}
|
||||
@ -1095,8 +1098,8 @@ int val_distcc(struct arg *arg, char **err_msg)
|
||||
/* convert the token name to an unsigned int (one byte per character,
|
||||
* big endian format).
|
||||
*/
|
||||
token = (arg[0].data.str.str[0] << 24) + (arg[0].data.str.str[1] << 16) +
|
||||
(arg[0].data.str.str[2] << 8) + (arg[0].data.str.str[3] << 0);
|
||||
token = (arg[0].data.str.area[0] << 24) + (arg[0].data.str.area[1] << 16) +
|
||||
(arg[0].data.str.area[2] << 8) + (arg[0].data.str.area[3] << 0);
|
||||
|
||||
arg[0].type = ARGT_SINT;
|
||||
arg[0].data.sint = token;
|
||||
|
150
src/peers.c
150
src/peers.c
@ -413,7 +413,7 @@ static int peer_prepare_switchmsg(struct shared_table *st, char *msg, size_t siz
|
||||
intencode(st->table->key_size, &cursor);
|
||||
|
||||
chunk = get_trash_chunk();
|
||||
chunkp = chunkq = chunk->str;
|
||||
chunkp = chunkq = chunk->area;
|
||||
/* encode available known data types in table */
|
||||
for (data_type = 0 ; data_type < STKTABLE_DATA_TYPES ; data_type++) {
|
||||
if (st->table->data_ofs[data_type]) {
|
||||
@ -437,9 +437,9 @@ static int peer_prepare_switchmsg(struct shared_table *st, char *msg, size_t siz
|
||||
intencode(st->table->expire, &cursor);
|
||||
|
||||
if (chunkq > chunkp) {
|
||||
chunk->len = chunkq - chunkp;
|
||||
memcpy(cursor, chunk->str, chunk->len);
|
||||
cursor += chunk->len;
|
||||
chunk->data = chunkq - chunkp;
|
||||
memcpy(cursor, chunk->area, chunk->data);
|
||||
cursor += chunk->data;
|
||||
}
|
||||
|
||||
/* Compute datalen */
|
||||
@ -588,31 +588,32 @@ switchstate:
|
||||
appctx->st0 = PEER_SESS_ST_GETVERSION;
|
||||
/* fall through */
|
||||
case PEER_SESS_ST_GETVERSION:
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.area,
|
||||
trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
}
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
if (trash.area[reql-1] != '\n') {
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
trash.str[reql-2] = 0;
|
||||
else if (reql > 1 && (trash.area[reql-2] == '\r'))
|
||||
trash.area[reql-2] = 0;
|
||||
else
|
||||
trash.str[reql-1] = 0;
|
||||
trash.area[reql-1] = 0;
|
||||
|
||||
co_skip(si_oc(si), reql);
|
||||
|
||||
/* test protocol */
|
||||
if (strncmp(PEER_SESSION_PROTO_NAME " ", trash.str, proto_len + 1) != 0) {
|
||||
if (strncmp(PEER_SESSION_PROTO_NAME " ", trash.area, proto_len + 1) != 0) {
|
||||
appctx->st0 = PEER_SESS_ST_EXIT;
|
||||
appctx->st1 = PEER_SESS_SC_ERRPROTO;
|
||||
goto switchstate;
|
||||
}
|
||||
if (peer_get_version(trash.str + proto_len + 1, &maj_ver, &min_ver) == -1 ||
|
||||
if (peer_get_version(trash.area + proto_len + 1, &maj_ver, &min_ver) == -1 ||
|
||||
maj_ver != PEER_MAJOR_VER || min_ver > PEER_MINOR_VER) {
|
||||
appctx->st0 = PEER_SESS_ST_EXIT;
|
||||
appctx->st1 = PEER_SESS_SC_ERRVERSION;
|
||||
@ -622,26 +623,27 @@ switchstate:
|
||||
appctx->st0 = PEER_SESS_ST_GETHOST;
|
||||
/* fall through */
|
||||
case PEER_SESS_ST_GETHOST:
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.area,
|
||||
trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
}
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
if (trash.area[reql-1] != '\n') {
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
trash.str[reql-2] = 0;
|
||||
else if (reql > 1 && (trash.area[reql-2] == '\r'))
|
||||
trash.area[reql-2] = 0;
|
||||
else
|
||||
trash.str[reql-1] = 0;
|
||||
trash.area[reql-1] = 0;
|
||||
|
||||
co_skip(si_oc(si), reql);
|
||||
|
||||
/* test hostname match */
|
||||
if (strcmp(localpeer, trash.str) != 0) {
|
||||
if (strcmp(localpeer, trash.area) != 0) {
|
||||
appctx->st0 = PEER_SESS_ST_EXIT;
|
||||
appctx->st1 = PEER_SESS_SC_ERRHOST;
|
||||
goto switchstate;
|
||||
@ -651,27 +653,28 @@ switchstate:
|
||||
/* fall through */
|
||||
case PEER_SESS_ST_GETPEER: {
|
||||
char *p;
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.area,
|
||||
trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
}
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
if (trash.area[reql-1] != '\n') {
|
||||
/* Incomplete line, we quit */
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
trash.str[reql-2] = 0;
|
||||
else if (reql > 1 && (trash.area[reql-2] == '\r'))
|
||||
trash.area[reql-2] = 0;
|
||||
else
|
||||
trash.str[reql-1] = 0;
|
||||
trash.area[reql-1] = 0;
|
||||
|
||||
co_skip(si_oc(si), reql);
|
||||
|
||||
/* parse line "<peer name> <pid> <relative_pid>" */
|
||||
p = strchr(trash.str, ' ');
|
||||
p = strchr(trash.area, ' ');
|
||||
if (!p) {
|
||||
appctx->st0 = PEER_SESS_ST_EXIT;
|
||||
appctx->st1 = PEER_SESS_SC_ERRPROTO;
|
||||
@ -681,7 +684,7 @@ switchstate:
|
||||
|
||||
/* lookup known peer */
|
||||
for (curpeer = curpeers->remote; curpeer; curpeer = curpeer->next) {
|
||||
if (strcmp(curpeer->id, trash.str) == 0)
|
||||
if (strcmp(curpeer->id, trash.area) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -732,8 +735,10 @@ switchstate:
|
||||
goto switchstate;
|
||||
}
|
||||
}
|
||||
repl = snprintf(trash.str, trash.size, "%d\n", PEER_SESS_SC_SUCCESSCODE);
|
||||
repl = ci_putblk(si_ic(si), trash.str, repl);
|
||||
repl = snprintf(trash.area, trash.size,
|
||||
"%d\n",
|
||||
PEER_SESS_SC_SUCCESSCODE);
|
||||
repl = ci_putblk(si_ic(si), trash.area, repl);
|
||||
if (repl <= 0) {
|
||||
if (repl == -1)
|
||||
goto full;
|
||||
@ -795,7 +800,7 @@ switchstate:
|
||||
}
|
||||
|
||||
/* Send headers */
|
||||
repl = snprintf(trash.str, trash.size,
|
||||
repl = snprintf(trash.area, trash.size,
|
||||
PEER_SESSION_PROTO_NAME " %u.%u\n%s\n%s %d %d\n",
|
||||
PEER_MAJOR_VER,
|
||||
(curpeer->flags & PEER_F_DWNGRD) ? PEER_DWNGRD_MINOR_VER : PEER_MINOR_VER,
|
||||
@ -809,7 +814,7 @@ switchstate:
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
repl = ci_putblk(si_ic(si), trash.str, repl);
|
||||
repl = ci_putblk(si_ic(si), trash.area, repl);
|
||||
if (repl <= 0) {
|
||||
if (repl == -1)
|
||||
goto full;
|
||||
@ -836,27 +841,28 @@ switchstate:
|
||||
if (si_ic(si)->flags & CF_WRITE_PARTIAL)
|
||||
curpeer->statuscode = PEER_SESS_SC_CONNECTEDCODE;
|
||||
|
||||
reql = co_getline(si_oc(si), trash.str, trash.size);
|
||||
reql = co_getline(si_oc(si), trash.area,
|
||||
trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
}
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
if (trash.area[reql-1] != '\n') {
|
||||
/* Incomplete line, we quit */
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
trash.str[reql-2] = 0;
|
||||
else if (reql > 1 && (trash.area[reql-2] == '\r'))
|
||||
trash.area[reql-2] = 0;
|
||||
else
|
||||
trash.str[reql-1] = 0;
|
||||
trash.area[reql-1] = 0;
|
||||
|
||||
co_skip(si_oc(si), reql);
|
||||
|
||||
/* Register status code */
|
||||
curpeer->statuscode = atoi(trash.str);
|
||||
curpeer->statuscode = atoi(trash.area);
|
||||
|
||||
/* Awake main task */
|
||||
task_wakeup(curpeers->sync_task, TASK_WOKEN_MSG);
|
||||
@ -906,8 +912,8 @@ switchstate:
|
||||
case PEER_SESS_ST_WAITMSG: {
|
||||
struct stksess *ts, *newts = NULL;
|
||||
uint32_t msg_len = 0;
|
||||
char *msg_cur = trash.str;
|
||||
char *msg_end = trash.str;
|
||||
char *msg_cur = trash.area;
|
||||
char *msg_end = trash.area;
|
||||
unsigned char msg_head[7];
|
||||
int totl = 0;
|
||||
|
||||
@ -978,7 +984,10 @@ switchstate:
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
reql = co_getblk(si_oc(si), trash.str, msg_len, totl);
|
||||
reql = co_getblk(si_oc(si),
|
||||
trash.area,
|
||||
msg_len,
|
||||
totl);
|
||||
if (reql <= 0) /* closed */
|
||||
goto incomplete;
|
||||
totl += reql;
|
||||
@ -1443,7 +1452,9 @@ incomplete:
|
||||
if (st->last_get != st->last_acked) {
|
||||
int msglen;
|
||||
|
||||
msglen = peer_prepare_ackmsg(st, trash.str, trash.size);
|
||||
msglen = peer_prepare_ackmsg(st,
|
||||
trash.area,
|
||||
trash.size);
|
||||
if (!msglen) {
|
||||
/* internal error: message does not fit in trash */
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
@ -1451,7 +1462,9 @@ incomplete:
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si),
|
||||
trash.area,
|
||||
msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1473,7 +1486,9 @@ incomplete:
|
||||
if (st != curpeer->last_local_table) {
|
||||
int msglen;
|
||||
|
||||
msglen = peer_prepare_switchmsg(st, trash.str, trash.size);
|
||||
msglen = peer_prepare_switchmsg(st,
|
||||
trash.area,
|
||||
trash.size);
|
||||
if (!msglen) {
|
||||
HA_SPIN_UNLOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
/* internal error: message does not fit in trash */
|
||||
@ -1482,7 +1497,9 @@ incomplete:
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si),
|
||||
trash.area,
|
||||
msglen);
|
||||
if (repl <= 0) {
|
||||
HA_SPIN_UNLOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
/* no more write possible */
|
||||
@ -1522,7 +1539,11 @@ incomplete:
|
||||
ts->ref_cnt++;
|
||||
HA_SPIN_UNLOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
|
||||
msglen = peer_prepare_updatemsg(ts, st, updateid, trash.str, trash.size, new_pushed, 0);
|
||||
msglen = peer_prepare_updatemsg(ts, st, updateid,
|
||||
trash.area,
|
||||
trash.size,
|
||||
new_pushed,
|
||||
0);
|
||||
if (!msglen) {
|
||||
/* internal error: message does not fit in trash */
|
||||
HA_SPIN_LOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
@ -1533,7 +1554,9 @@ incomplete:
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si),
|
||||
trash.area,
|
||||
msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
HA_SPIN_LOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
@ -1565,7 +1588,9 @@ incomplete:
|
||||
if (st != curpeer->last_local_table) {
|
||||
int msglen;
|
||||
|
||||
msglen = peer_prepare_switchmsg(st, trash.str, trash.size);
|
||||
msglen = peer_prepare_switchmsg(st,
|
||||
trash.area,
|
||||
trash.size);
|
||||
if (!msglen) {
|
||||
/* internal error: message does not fit in trash */
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
@ -1573,7 +1598,9 @@ incomplete:
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si),
|
||||
trash.area,
|
||||
msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1610,7 +1637,11 @@ incomplete:
|
||||
HA_SPIN_UNLOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
|
||||
use_timed = !(curpeer->flags & PEER_F_DWNGRD);
|
||||
msglen = peer_prepare_updatemsg(ts, st, updateid, trash.str, trash.size, new_pushed, use_timed);
|
||||
msglen = peer_prepare_updatemsg(ts, st, updateid,
|
||||
trash.area,
|
||||
trash.size,
|
||||
new_pushed,
|
||||
use_timed);
|
||||
if (!msglen) {
|
||||
/* internal error: message does not fit in trash */
|
||||
HA_SPIN_LOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
@ -1621,7 +1652,9 @@ incomplete:
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si),
|
||||
trash.area,
|
||||
msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
HA_SPIN_LOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
@ -1649,7 +1682,9 @@ incomplete:
|
||||
if (st != curpeer->last_local_table) {
|
||||
int msglen;
|
||||
|
||||
msglen = peer_prepare_switchmsg(st, trash.str, trash.size);
|
||||
msglen = peer_prepare_switchmsg(st,
|
||||
trash.area,
|
||||
trash.size);
|
||||
if (!msglen) {
|
||||
/* internal error: message does not fit in trash */
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
@ -1657,7 +1692,9 @@ incomplete:
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si),
|
||||
trash.area,
|
||||
msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
if (repl == -1) {
|
||||
@ -1693,7 +1730,11 @@ incomplete:
|
||||
HA_SPIN_UNLOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
|
||||
use_timed = !(curpeer->flags & PEER_F_DWNGRD);
|
||||
msglen = peer_prepare_updatemsg(ts, st, updateid, trash.str, trash.size, new_pushed, use_timed);
|
||||
msglen = peer_prepare_updatemsg(ts, st, updateid,
|
||||
trash.area,
|
||||
trash.size,
|
||||
new_pushed,
|
||||
use_timed);
|
||||
if (!msglen) {
|
||||
/* internal error: message does not fit in trash */
|
||||
HA_SPIN_LOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
@ -1704,7 +1745,9 @@ incomplete:
|
||||
}
|
||||
|
||||
/* message to buffer */
|
||||
repl = ci_putblk(si_ic(si), trash.str, msglen);
|
||||
repl = ci_putblk(si_ic(si),
|
||||
trash.area,
|
||||
msglen);
|
||||
if (repl <= 0) {
|
||||
/* no more write possible */
|
||||
HA_SPIN_LOCK(STK_TABLE_LOCK, &st->table->lock);
|
||||
@ -1777,8 +1820,9 @@ incomplete:
|
||||
goto out;
|
||||
}
|
||||
case PEER_SESS_ST_EXIT:
|
||||
repl = snprintf(trash.str, trash.size, "%d\n", appctx->st1);
|
||||
if (ci_putblk(si_ic(si), trash.str, repl) == -1)
|
||||
repl = snprintf(trash.area, trash.size,
|
||||
"%d\n", appctx->st1);
|
||||
if (ci_putblk(si_ic(si), trash.area, repl) == -1)
|
||||
goto full;
|
||||
appctx->st0 = PEER_SESS_ST_END;
|
||||
goto switchstate;
|
||||
|
736
src/proto_http.c
736
src/proto_http.c
File diff suppressed because it is too large
Load Diff
@ -631,7 +631,8 @@ int tcp_drain(int fd)
|
||||
len = recv(fd, NULL, INT_MAX, MSG_DONTWAIT | MSG_NOSIGNAL | MSG_TRUNC);
|
||||
if (len == -1 && errno == EFAULT)
|
||||
#endif
|
||||
len = recv(fd, trash.str, trash.size, MSG_DONTWAIT | MSG_NOSIGNAL);
|
||||
len = recv(fd, trash.area, trash.size,
|
||||
MSG_DONTWAIT | MSG_NOSIGNAL);
|
||||
|
||||
if (len == 0) {
|
||||
/* cool, shutdown received */
|
||||
@ -1636,9 +1637,9 @@ static inline int get_tcp_info(const struct arg *args, struct sample *smp,
|
||||
/* Convert the value as expected. */
|
||||
if (args) {
|
||||
if (args[0].type == ARGT_STR) {
|
||||
if (strcmp(args[0].data.str.str, "us") == 0) {
|
||||
if (strcmp(args[0].data.str.area, "us") == 0) {
|
||||
/* Do nothing. */
|
||||
} else if (strcmp(args[0].data.str.str, "ms") == 0) {
|
||||
} else if (strcmp(args[0].data.str.area, "ms") == 0) {
|
||||
smp->data.u.sint = (smp->data.u.sint + 500) / 1000;
|
||||
} else
|
||||
return 0;
|
||||
|
476
src/sample.c
476
src/sample.c
File diff suppressed because it is too large
Load Diff
106
src/server.c
106
src/server.c
@ -142,7 +142,7 @@ void srv_set_dyncookie(struct server *s)
|
||||
* on the safe side.
|
||||
*/
|
||||
buffer_len = key_len + addr_len + 4;
|
||||
tmpbuf = trash.str;
|
||||
tmpbuf = trash.area;
|
||||
memcpy(tmpbuf, p->dyncookie_key, key_len);
|
||||
memcpy(&(tmpbuf[key_len]),
|
||||
s->addr.ss_family == AF_INET ?
|
||||
@ -1437,7 +1437,7 @@ static int srv_prepare_for_resolution(struct server *srv, const char *hostname)
|
||||
return 0;
|
||||
|
||||
hostname_len = strlen(hostname);
|
||||
hostname_dn = trash.str;
|
||||
hostname_dn = trash.area;
|
||||
hostname_dn_len = dns_str_to_dn_label(hostname, hostname_len + 1,
|
||||
hostname_dn, trash.size);
|
||||
if (hostname_dn_len == -1)
|
||||
@ -1826,9 +1826,9 @@ static int srv_tmpl_parse_range(struct server *srv, const char *arg, int *nb_low
|
||||
|
||||
*nb_high = 0;
|
||||
chunk_printf(&trash, "%s", arg);
|
||||
*nb_low = atoi(trash.str);
|
||||
*nb_low = atoi(trash.area);
|
||||
|
||||
if ((nb_high_arg = strchr(trash.str, '-'))) {
|
||||
if ((nb_high_arg = strchr(trash.area, '-'))) {
|
||||
*nb_high_arg++ = '\0';
|
||||
*nb_high = atoi(nb_high_arg);
|
||||
}
|
||||
@ -1847,7 +1847,7 @@ static inline void srv_set_id_from_prefix(struct server *srv, const char *prefix
|
||||
{
|
||||
chunk_printf(&trash, "%s%d", prefix, nb);
|
||||
free(srv->id);
|
||||
srv->id = strdup(trash.str);
|
||||
srv->id = strdup(trash.area);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2861,7 +2861,7 @@ static void srv_update_state(struct server *srv, int version, char **params)
|
||||
}
|
||||
|
||||
/* don't apply anything if one error has been detected */
|
||||
if (msg->len)
|
||||
if (msg->data)
|
||||
goto out;
|
||||
|
||||
HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
|
||||
@ -3003,10 +3003,10 @@ static void srv_update_state(struct server *srv, int version, char **params)
|
||||
}
|
||||
|
||||
out:
|
||||
if (msg->len) {
|
||||
if (msg->data) {
|
||||
chunk_appendf(msg, "\n");
|
||||
ha_warning("server-state application failed for server '%s/%s'%s",
|
||||
srv->proxy->id, srv->id, msg->str);
|
||||
srv->proxy->id, srv->id, msg->area);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3370,10 +3370,10 @@ int update_server_addr(struct server *s, void *ip, int ip_sin_family, const char
|
||||
s->proxy->id, s->id, oldip, newip, updater);
|
||||
|
||||
/* write the buffer on stderr */
|
||||
ha_warning("%s.\n", trash.str);
|
||||
ha_warning("%s.\n", trash.area);
|
||||
|
||||
/* send a log */
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.area);
|
||||
}
|
||||
|
||||
/* save the new IP family */
|
||||
@ -3559,7 +3559,7 @@ out:
|
||||
if (updater)
|
||||
chunk_appendf(msg, " by '%s'", updater);
|
||||
chunk_appendf(msg, "\n");
|
||||
return msg->str;
|
||||
return msg->area;
|
||||
}
|
||||
|
||||
|
||||
@ -3600,8 +3600,8 @@ int snr_update_srv_status(struct server *s, int has_no_ip)
|
||||
chunk_printf(&trash, "Server %s/%s administratively READY thanks to valid DNS answer",
|
||||
s->proxy->id, s->id);
|
||||
|
||||
ha_warning("%s.\n", trash.str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
|
||||
ha_warning("%s.\n", trash.area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.area);
|
||||
return 0;
|
||||
|
||||
case RSLV_STATUS_NX:
|
||||
@ -3743,7 +3743,7 @@ int snr_resolution_cb(struct dns_requester *requester, struct dns_nameserver *na
|
||||
}
|
||||
else
|
||||
chunk_printf(chk, "DNS cache");
|
||||
update_server_addr(s, firstip, firstip_sin_family, (char *)chk->str);
|
||||
update_server_addr(s, firstip, firstip_sin_family, (char *) chk->area);
|
||||
|
||||
update_status:
|
||||
snr_update_srv_status(s, has_no_ip);
|
||||
@ -3873,7 +3873,7 @@ int srv_set_fqdn(struct server *srv, const char *hostname, int dns_locked)
|
||||
|
||||
chunk_reset(&trash);
|
||||
hostname_len = strlen(hostname);
|
||||
hostname_dn = trash.str;
|
||||
hostname_dn = trash.area;
|
||||
hostname_dn_len = dns_str_to_dn_label(hostname, hostname_len + 1,
|
||||
hostname_dn, trash.size);
|
||||
if (hostname_dn_len == -1)
|
||||
@ -4068,7 +4068,7 @@ const char *update_server_fqdn(struct server *server, const char *fqdn, const ch
|
||||
chunk_appendf(msg, " by '%s'", updater);
|
||||
chunk_appendf(msg, "\n");
|
||||
|
||||
return msg->str;
|
||||
return msg->area;
|
||||
}
|
||||
|
||||
|
||||
@ -4329,8 +4329,9 @@ static int cli_parse_get_weight(char **args, char *payload, struct appctx *appct
|
||||
}
|
||||
|
||||
/* return server's effective weight at the moment */
|
||||
snprintf(trash.str, trash.size, "%d (initial %d)\n", sv->uweight, sv->iweight);
|
||||
if (ci_putstr(si_ic(si), trash.str) == -1) {
|
||||
snprintf(trash.area, trash.size, "%d (initial %d)\n", sv->uweight,
|
||||
sv->iweight);
|
||||
if (ci_putstr(si_ic(si), trash.area) == -1) {
|
||||
si_applet_cant_put(si);
|
||||
return 0;
|
||||
}
|
||||
@ -4557,12 +4558,14 @@ void srv_update_status(struct server *s)
|
||||
s->proxy->id, s->id);
|
||||
|
||||
srv_append_status(tmptrash, s, NULL, xferred, 0);
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
|
||||
/* we don't send an alert if the server was previously paused */
|
||||
log_level = srv_was_stopping ? LOG_NOTICE : LOG_ALERT;
|
||||
send_log(s->proxy, log_level, "%s.\n", tmptrash->str);
|
||||
send_email_alert(s, log_level, "%s", tmptrash->str);
|
||||
send_log(s->proxy, log_level, "%s.\n",
|
||||
tmptrash->area);
|
||||
send_email_alert(s, log_level, "%s",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
@ -4590,8 +4593,9 @@ void srv_update_status(struct server *s)
|
||||
|
||||
srv_append_status(tmptrash, s, NULL, xferred, 0);
|
||||
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
@ -4648,9 +4652,11 @@ void srv_update_status(struct server *s)
|
||||
s->proxy->id, s->id);
|
||||
|
||||
srv_append_status(tmptrash, s, NULL, xferred, 0);
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
send_email_alert(s, LOG_NOTICE, "%s", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
send_email_alert(s, LOG_NOTICE, "%s",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
@ -4703,8 +4709,9 @@ void srv_update_status(struct server *s)
|
||||
srv_append_status(tmptrash, s, NULL, -1, (s->next_admin & SRV_ADMF_FMAINT));
|
||||
|
||||
if (!(global.mode & MODE_STARTING)) {
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
}
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
@ -4741,8 +4748,9 @@ void srv_update_status(struct server *s)
|
||||
srv_append_status(tmptrash, s, NULL, xferred, (s->next_admin & SRV_ADMF_FMAINT));
|
||||
|
||||
if (!(global.mode & MODE_STARTING)) {
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, srv_was_stopping ? LOG_NOTICE : LOG_ALERT, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, srv_was_stopping ? LOG_NOTICE : LOG_ALERT, "%s.\n",
|
||||
tmptrash->area);
|
||||
}
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
@ -4817,8 +4825,9 @@ void srv_update_status(struct server *s)
|
||||
(s->next_state == SRV_ST_STOPPED) ? "DOWN" : "UP",
|
||||
(s->next_admin & SRV_ADMF_DRAIN) ? "DRAIN" : "READY");
|
||||
}
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
@ -4855,8 +4864,9 @@ void srv_update_status(struct server *s)
|
||||
if (s->track) /* normally it's mandatory here */
|
||||
chunk_appendf(tmptrash, " via %s/%s",
|
||||
s->track->proxy->id, s->track->id);
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
@ -4872,8 +4882,9 @@ void srv_update_status(struct server *s)
|
||||
if (s->track) /* normally it's mandatory here */
|
||||
chunk_appendf(tmptrash, " via %s/%s",
|
||||
s->track->proxy->id, s->track->id);
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
@ -4885,8 +4896,9 @@ void srv_update_status(struct server *s)
|
||||
"%sServer %s/%s remains in forced maintenance",
|
||||
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
||||
s->proxy->id, s->id);
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
@ -4919,9 +4931,11 @@ void srv_update_status(struct server *s)
|
||||
srv_append_status(tmptrash, s, NULL, xferred, (s->next_admin & SRV_ADMF_FDRAIN));
|
||||
|
||||
if (!(global.mode & MODE_STARTING)) {
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
send_email_alert(s, LOG_NOTICE, "%s", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
send_email_alert(s, LOG_NOTICE, "%s",
|
||||
tmptrash->area);
|
||||
}
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
@ -4963,8 +4977,9 @@ void srv_update_status(struct server *s)
|
||||
s->track->proxy->id, s->track->id);
|
||||
}
|
||||
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
@ -5002,8 +5017,9 @@ void srv_update_status(struct server *s)
|
||||
s->flags & SRV_F_BACKUP ? "Backup " : "",
|
||||
s->proxy->id, s->id);
|
||||
}
|
||||
ha_warning("%s.\n", tmptrash->str);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str);
|
||||
ha_warning("%s.\n", tmptrash->area);
|
||||
send_log(s->proxy, LOG_NOTICE, "%s.\n",
|
||||
tmptrash->area);
|
||||
free_trash_chunk(tmptrash);
|
||||
tmptrash = NULL;
|
||||
}
|
||||
|
@ -282,9 +282,10 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
|
||||
if (ret < 0 && l->bind_conf->xprt == xprt_get(XPRT_RAW) && p->mode == PR_MODE_HTTP) {
|
||||
/* critical error, no more memory, try to emit a 500 response */
|
||||
struct chunk *err_msg = &p->errmsg[HTTP_ERR_500];
|
||||
if (!err_msg->str)
|
||||
if (!err_msg->area)
|
||||
err_msg = &http_err_chunks[HTTP_ERR_500];
|
||||
send(cfd, err_msg->str, err_msg->len, MSG_DONTWAIT|MSG_NOSIGNAL);
|
||||
send(cfd, err_msg->area, err_msg->data,
|
||||
MSG_DONTWAIT|MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
if (fdtab[cfd].owner)
|
||||
@ -316,8 +317,9 @@ static void session_prepare_log_prefix(struct session *sess)
|
||||
chunk_printf(&trash, "%s:%d [", pn, get_host_port(&cli_conn->addr.from));
|
||||
|
||||
get_localtime(sess->accept_date.tv_sec, &tm);
|
||||
end = date2str_log(trash.str + trash.len, &tm, &(sess->accept_date), trash.size - trash.len);
|
||||
trash.len = end - trash.str;
|
||||
end = date2str_log(trash.area + trash.data, &tm, &(sess->accept_date),
|
||||
trash.size - trash.data);
|
||||
trash.data = end - trash.area;
|
||||
if (sess->listener->name)
|
||||
chunk_appendf(&trash, "] %s/%s", sess->fe->id, sess->listener->name);
|
||||
else
|
||||
@ -362,10 +364,11 @@ static void session_kill_embryonic(struct session *sess)
|
||||
session_prepare_log_prefix(sess);
|
||||
err_msg = conn_err_code_str(conn);
|
||||
if (err_msg)
|
||||
send_log(sess->fe, level, "%s: %s\n", trash.str, err_msg);
|
||||
send_log(sess->fe, level, "%s: %s\n", trash.area,
|
||||
err_msg);
|
||||
else
|
||||
send_log(sess->fe, level, "%s: unknown connection error (code=%d flags=%08x)\n",
|
||||
trash.str, conn->err_code, conn->flags);
|
||||
trash.area, conn->err_code, conn->flags);
|
||||
}
|
||||
|
||||
/* kill the connection now */
|
||||
|
225
src/ssl_sock.c
225
src/ssl_sock.c
@ -64,6 +64,7 @@
|
||||
#include <import/xxhash.h>
|
||||
|
||||
#include <common/buffer.h>
|
||||
#include <common/chunk.h>
|
||||
#include <common/compat.h>
|
||||
#include <common/config.h>
|
||||
#include <common/debug.h>
|
||||
@ -649,13 +650,14 @@ static int ssl_sock_load_ocsp_response(struct chunk *ocsp_response, struct certi
|
||||
OCSP_BASICRESP *bs = NULL;
|
||||
OCSP_SINGLERESP *sr;
|
||||
OCSP_CERTID *id;
|
||||
unsigned char *p = (unsigned char *)ocsp_response->str;
|
||||
unsigned char *p = (unsigned char *) ocsp_response->area;
|
||||
int rc , count_sr;
|
||||
ASN1_GENERALIZEDTIME *revtime, *thisupd, *nextupd = NULL;
|
||||
int reason;
|
||||
int ret = 1;
|
||||
|
||||
resp = d2i_OCSP_RESPONSE(NULL, (const unsigned char **)&p, ocsp_response->len);
|
||||
resp = d2i_OCSP_RESPONSE(NULL, (const unsigned char **)&p,
|
||||
ocsp_response->data);
|
||||
if (!resp) {
|
||||
memprintf(err, "Unable to parse OCSP response");
|
||||
goto out;
|
||||
@ -787,9 +789,9 @@ static int ssl_sock_load_ocsp_response_from_file(const char *ocsp_path, struct c
|
||||
goto end;
|
||||
}
|
||||
|
||||
trash.len = 0;
|
||||
while (trash.len < trash.size) {
|
||||
r = read(fd, trash.str + trash.len, trash.size - trash.len);
|
||||
trash.data = 0;
|
||||
while (trash.data < trash.size) {
|
||||
r = read(fd, trash.area + trash.data, trash.size - trash.data);
|
||||
if (r < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
@ -800,7 +802,7 @@ static int ssl_sock_load_ocsp_response_from_file(const char *ocsp_path, struct c
|
||||
else if (r == 0) {
|
||||
break;
|
||||
}
|
||||
trash.len += r;
|
||||
trash.data += r;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
@ -887,7 +889,8 @@ struct tls_keys_ref *tlskeys_ref_lookupid(int unique_id)
|
||||
void ssl_sock_update_tlskey_ref(struct tls_keys_ref *ref, struct chunk *tlskey)
|
||||
{
|
||||
HA_RWLOCK_WRLOCK(TLSKEYS_REF_LOCK, &ref->lock);
|
||||
memcpy((char *) (ref->tlskeys + ((ref->tls_ticket_enc_index + 2) % TLS_TICKETS_NO)), tlskey->str, tlskey->len);
|
||||
memcpy((char *) (ref->tlskeys + ((ref->tls_ticket_enc_index + 2) % TLS_TICKETS_NO)),
|
||||
tlskey->area, tlskey->data);
|
||||
ref->tls_ticket_enc_index = (ref->tls_ticket_enc_index + 1) % TLS_TICKETS_NO;
|
||||
HA_RWLOCK_WRUNLOCK(TLSKEYS_REF_LOCK, &ref->lock);
|
||||
}
|
||||
@ -1005,17 +1008,17 @@ int ssl_sock_ocsp_stapling_cbk(SSL *ssl, void *arg)
|
||||
}
|
||||
|
||||
if (!ocsp ||
|
||||
!ocsp->response.str ||
|
||||
!ocsp->response.len ||
|
||||
!ocsp->response.area ||
|
||||
!ocsp->response.data ||
|
||||
(ocsp->expire < now.tv_sec))
|
||||
return SSL_TLSEXT_ERR_NOACK;
|
||||
|
||||
ssl_buf = OPENSSL_malloc(ocsp->response.len);
|
||||
ssl_buf = OPENSSL_malloc(ocsp->response.data);
|
||||
if (!ssl_buf)
|
||||
return SSL_TLSEXT_ERR_NOACK;
|
||||
|
||||
memcpy(ssl_buf, ocsp->response.str, ocsp->response.len);
|
||||
SSL_set_tlsext_status_ocsp_resp(ssl, ssl_buf, ocsp->response.len);
|
||||
memcpy(ssl_buf, ocsp->response.area, ocsp->response.data);
|
||||
SSL_set_tlsext_status_ocsp_resp(ssl, ssl_buf, ocsp->response.data);
|
||||
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
@ -1232,9 +1235,9 @@ static int ssl_sock_set_ocsp_response_from_file(SSL_CTX *ctx, const char *cert_p
|
||||
return -1;
|
||||
}
|
||||
|
||||
trash.len = 0;
|
||||
while (trash.len < trash.size) {
|
||||
r = read(fd, trash.str + trash.len, trash.size - trash.len);
|
||||
trash.data = 0;
|
||||
while (trash.data < trash.size) {
|
||||
r = read(fd, trash.area + trash.data, trash.size - trash.data);
|
||||
if (r < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
@ -1245,10 +1248,11 @@ static int ssl_sock_set_ocsp_response_from_file(SSL_CTX *ctx, const char *cert_p
|
||||
else if (r == 0) {
|
||||
break;
|
||||
}
|
||||
trash.len += r;
|
||||
trash.data += r;
|
||||
}
|
||||
close(fd);
|
||||
return SSL_CTX_set_ocsp_response(ctx, (const uint8_t *)trash.str, trash.len);
|
||||
return SSL_CTX_set_ocsp_response(ctx, (const uint8_t *) trash.area,
|
||||
trash.data);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1269,13 +1273,13 @@ static int ssl_sock_parse_sctl(struct chunk *sctl)
|
||||
int len, pos, sct_len;
|
||||
unsigned char *data;
|
||||
|
||||
if (sctl->len < 2)
|
||||
if (sctl->data < 2)
|
||||
goto out;
|
||||
|
||||
data = (unsigned char *)sctl->str;
|
||||
data = (unsigned char *) sctl->area;
|
||||
len = (data[0] << 8) | data[1];
|
||||
|
||||
if (len + 2 != sctl->len)
|
||||
if (len + 2 != sctl->data)
|
||||
goto out;
|
||||
|
||||
data = data + 2;
|
||||
@ -1309,9 +1313,9 @@ static int ssl_sock_load_sctl_from_file(const char *sctl_path, struct chunk **sc
|
||||
if (fd == -1)
|
||||
goto end;
|
||||
|
||||
trash.len = 0;
|
||||
while (trash.len < trash.size) {
|
||||
r = read(fd, trash.str + trash.len, trash.size - trash.len);
|
||||
trash.data = 0;
|
||||
while (trash.data < trash.size) {
|
||||
r = read(fd, trash.area + trash.data, trash.size - trash.data);
|
||||
if (r < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
@ -1321,7 +1325,7 @@ static int ssl_sock_load_sctl_from_file(const char *sctl_path, struct chunk **sc
|
||||
else if (r == 0) {
|
||||
break;
|
||||
}
|
||||
trash.len += r;
|
||||
trash.data += r;
|
||||
}
|
||||
|
||||
ret = ssl_sock_parse_sctl(&trash);
|
||||
@ -1346,8 +1350,8 @@ int ssl_sock_sctl_add_cbk(SSL *ssl, unsigned ext_type, const unsigned char **out
|
||||
{
|
||||
struct chunk *sctl = add_arg;
|
||||
|
||||
*out = (unsigned char *)sctl->str;
|
||||
*outlen = sctl->len;
|
||||
*out = (unsigned char *) sctl->area;
|
||||
*outlen = sctl->data;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -2219,14 +2223,14 @@ static int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *arg)
|
||||
}
|
||||
|
||||
for (i = 0; i < trash.size && i < servername_len; i++) {
|
||||
trash.str[i] = tolower(servername[i]);
|
||||
if (!wildp && (trash.str[i] == '.'))
|
||||
wildp = &trash.str[i];
|
||||
trash.area[i] = tolower(servername[i]);
|
||||
if (!wildp && (trash.area[i] == '.'))
|
||||
wildp = &trash.area[i];
|
||||
}
|
||||
trash.str[i] = 0;
|
||||
trash.area[i] = 0;
|
||||
|
||||
/* lookup in full qualified names */
|
||||
node = ebst_lookup(&s->sni_ctx, trash.str);
|
||||
node = ebst_lookup(&s->sni_ctx, trash.area);
|
||||
|
||||
/* lookup a not neg filter */
|
||||
for (n = node; n; n = ebmb_next_dup(n)) {
|
||||
@ -2296,7 +2300,7 @@ static int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *arg)
|
||||
goto allow_early;
|
||||
}
|
||||
#if (!defined SSL_NO_GENERATE_CERTIFICATES)
|
||||
if (s->generate_certs && ssl_sock_generate_certificate(trash.str, s, ssl)) {
|
||||
if (s->generate_certs && ssl_sock_generate_certificate(trash.area, s, ssl)) {
|
||||
/* switch ctx done in ssl_sock_generate_certificate */
|
||||
goto allow_early;
|
||||
}
|
||||
@ -2355,14 +2359,14 @@ static int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *priv)
|
||||
for (i = 0; i < trash.size; i++) {
|
||||
if (!servername[i])
|
||||
break;
|
||||
trash.str[i] = tolower(servername[i]);
|
||||
if (!wildp && (trash.str[i] == '.'))
|
||||
wildp = &trash.str[i];
|
||||
trash.area[i] = tolower(servername[i]);
|
||||
if (!wildp && (trash.area[i] == '.'))
|
||||
wildp = &trash.area[i];
|
||||
}
|
||||
trash.str[i] = 0;
|
||||
trash.area[i] = 0;
|
||||
|
||||
/* lookup in full qualified names */
|
||||
node = ebst_lookup(&s->sni_ctx, trash.str);
|
||||
node = ebst_lookup(&s->sni_ctx, trash.area);
|
||||
|
||||
/* lookup a not neg filter */
|
||||
for (n = node; n; n = ebmb_next_dup(n)) {
|
||||
@ -2685,16 +2689,16 @@ static int ssl_sock_add_cert_sni(SSL_CTX *ctx, struct bind_conf *s, struct ssl_b
|
||||
int j, len;
|
||||
len = strlen(name);
|
||||
for (j = 0; j < len && j < trash.size; j++)
|
||||
trash.str[j] = tolower(name[j]);
|
||||
trash.area[j] = tolower(name[j]);
|
||||
if (j >= trash.size)
|
||||
return order;
|
||||
trash.str[j] = 0;
|
||||
trash.area[j] = 0;
|
||||
|
||||
/* Check for duplicates. */
|
||||
if (wild)
|
||||
node = ebst_lookup(&s->sni_w_ctx, trash.str);
|
||||
node = ebst_lookup(&s->sni_w_ctx, trash.area);
|
||||
else
|
||||
node = ebst_lookup(&s->sni_ctx, trash.str);
|
||||
node = ebst_lookup(&s->sni_ctx, trash.area);
|
||||
for (; node; node = ebmb_next_dup(node)) {
|
||||
sc = ebmb_entry(node, struct sni_ctx, name);
|
||||
if (sc->ctx == ctx && sc->conf == conf && sc->neg == neg)
|
||||
@ -2704,7 +2708,7 @@ static int ssl_sock_add_cert_sni(SSL_CTX *ctx, struct bind_conf *s, struct ssl_b
|
||||
sc = malloc(sizeof(struct sni_ctx) + len + 1);
|
||||
if (!sc)
|
||||
return order;
|
||||
memcpy(sc->name.key, trash.str, len + 1);
|
||||
memcpy(sc->name.key, trash.area, len + 1);
|
||||
sc->ctx = ctx;
|
||||
sc->conf = conf;
|
||||
sc->kinfo = kinfo;
|
||||
@ -2929,10 +2933,10 @@ static void ssl_sock_populate_sni_keytypes_hplr(const char *str, struct eb_root
|
||||
for (i = 0; i < trash.size; i++) {
|
||||
if (!str[i])
|
||||
break;
|
||||
trash.str[i] = tolower(str[i]);
|
||||
trash.area[i] = tolower(str[i]);
|
||||
}
|
||||
trash.str[i] = 0;
|
||||
node = ebst_lookup(sni_keytypes, trash.str);
|
||||
trash.area[i] = 0;
|
||||
node = ebst_lookup(sni_keytypes, trash.area);
|
||||
if (!node) {
|
||||
/* CN not found in tree */
|
||||
s_kt = malloc(sizeof(struct sni_keytype) + i + 1);
|
||||
@ -2940,7 +2944,7 @@ static void ssl_sock_populate_sni_keytypes_hplr(const char *str, struct eb_root
|
||||
* strncpy will cause sig_abrt errors under certain versions of gcc with -O2
|
||||
* See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60792
|
||||
*/
|
||||
memcpy(s_kt->name.key, trash.str, i+1);
|
||||
memcpy(s_kt->name.key, trash.area, i+1);
|
||||
s_kt->keytypes = 0;
|
||||
ebst_insert(sni_keytypes, &s_kt->name);
|
||||
} else {
|
||||
@ -5822,8 +5826,8 @@ ssl_sock_get_serial(X509 *crt, struct chunk *out)
|
||||
if (out->size < serial->length)
|
||||
return -1;
|
||||
|
||||
memcpy(out->str, serial->data, serial->length);
|
||||
out->len = serial->length;
|
||||
memcpy(out->area, serial->data, serial->length);
|
||||
out->data = serial->length;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -5835,7 +5839,7 @@ static int
|
||||
ssl_sock_crt2der(X509 *crt, struct chunk *out)
|
||||
{
|
||||
int len;
|
||||
unsigned char *p = (unsigned char *)out->str;;
|
||||
unsigned char *p = (unsigned char *) out->area;;
|
||||
|
||||
len =i2d_X509(crt, NULL);
|
||||
if (len <= 0)
|
||||
@ -5845,7 +5849,7 @@ ssl_sock_crt2der(X509 *crt, struct chunk *out)
|
||||
return -1;
|
||||
|
||||
i2d_X509(crt,&p);
|
||||
out->len = len;
|
||||
out->data = len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -5867,8 +5871,8 @@ ssl_sock_get_time(ASN1_TIME *tm, struct chunk *out)
|
||||
if (out->size < gentm->length-2)
|
||||
return -1;
|
||||
|
||||
memcpy(out->str, gentm->data+2, gentm->length-2);
|
||||
out->len = gentm->length-2;
|
||||
memcpy(out->area, gentm->data+2, gentm->length-2);
|
||||
out->data = gentm->length-2;
|
||||
return 1;
|
||||
}
|
||||
else if (tm->type == V_ASN1_UTCTIME) {
|
||||
@ -5881,8 +5885,8 @@ ssl_sock_get_time(ASN1_TIME *tm, struct chunk *out)
|
||||
if (out->size < utctm->length)
|
||||
return -1;
|
||||
|
||||
memcpy(out->str, utctm->data, utctm->length);
|
||||
out->len = utctm->length;
|
||||
memcpy(out->area, utctm->data, utctm->length);
|
||||
out->data = utctm->length;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -5908,7 +5912,7 @@ ssl_sock_get_dn_entry(X509_NAME *a, const struct chunk *entry, int pos, struct c
|
||||
|
||||
name_count = X509_NAME_entry_count(a);
|
||||
|
||||
out->len = 0;
|
||||
out->data = 0;
|
||||
for (i = 0; i < name_count; i++) {
|
||||
if (pos < 0)
|
||||
j = (name_count-1) - i;
|
||||
@ -5940,8 +5944,8 @@ ssl_sock_get_dn_entry(X509_NAME *a, const struct chunk *entry, int pos, struct c
|
||||
if (data_len > out->size)
|
||||
return -1;
|
||||
|
||||
memcpy(out->str, data_ptr, data_len);
|
||||
out->len = data_len;
|
||||
memcpy(out->area, data_ptr, data_len);
|
||||
out->data = data_len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -5970,8 +5974,8 @@ ssl_sock_get_dn_oneline(X509_NAME *a, struct chunk *out)
|
||||
|
||||
name_count = X509_NAME_entry_count(a);
|
||||
|
||||
out->len = 0;
|
||||
p = out->str;
|
||||
out->data = 0;
|
||||
p = out->area;
|
||||
for (i = 0; i < name_count; i++) {
|
||||
ne = X509_NAME_get_entry(a, i);
|
||||
obj = X509_NAME_ENTRY_get_object(ne);
|
||||
@ -5988,7 +5992,7 @@ ssl_sock_get_dn_oneline(X509_NAME *a, struct chunk *out)
|
||||
l += 1 + ln + 1 + data_len;
|
||||
if (l > out->size)
|
||||
return -1;
|
||||
out->len = l;
|
||||
out->data = l;
|
||||
|
||||
*(p++)='/';
|
||||
memcpy(p, s, ln);
|
||||
@ -5998,7 +6002,7 @@ ssl_sock_get_dn_oneline(X509_NAME *a, struct chunk *out)
|
||||
p += data_len;
|
||||
}
|
||||
|
||||
if (!out->len)
|
||||
if (!out->data)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -6041,8 +6045,8 @@ int ssl_sock_get_remote_common_name(struct connection *conn, struct chunk *dest)
|
||||
X509_NAME *name;
|
||||
const char find_cn[] = "CN";
|
||||
const struct chunk find_cn_chunk = {
|
||||
.str = (char *)&find_cn,
|
||||
.len = sizeof(find_cn)-1
|
||||
.area = (char *)&find_cn,
|
||||
.data = sizeof(find_cn)-1
|
||||
};
|
||||
int result = -1;
|
||||
|
||||
@ -6288,7 +6292,8 @@ smp_fetch_ssl_x_sha1(const struct arg *args, struct sample *smp, const char *kw,
|
||||
|
||||
smp_trash = get_trash_chunk();
|
||||
digest = EVP_sha1();
|
||||
X509_digest(crt, digest, (unsigned char *)smp_trash->str, (unsigned int *)&smp_trash->len);
|
||||
X509_digest(crt, digest, (unsigned char *) smp_trash->area,
|
||||
(unsigned int *)&smp_trash->data);
|
||||
|
||||
smp->data.u.str = *smp_trash;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
@ -6595,8 +6600,8 @@ smp_fetch_ssl_x_sig_alg(const struct arg *args, struct sample *smp, const char *
|
||||
X509_ALGOR_get0(&algorithm, NULL, NULL, X509_get0_tbs_sigalg(crt));
|
||||
nid = OBJ_obj2nid(algorithm);
|
||||
|
||||
smp->data.u.str.str = (char *)OBJ_nid2sn(nid);
|
||||
if (!smp->data.u.str.str) {
|
||||
smp->data.u.str.area = (char *)OBJ_nid2sn(nid);
|
||||
if (!smp->data.u.str.area) {
|
||||
/* SSL_get_peer_certificate increase X509 * ref count */
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
@ -6605,7 +6610,7 @@ smp_fetch_ssl_x_sig_alg(const struct arg *args, struct sample *smp, const char *
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.u.str.len = strlen(smp->data.u.str.str);
|
||||
smp->data.u.str.data = strlen(smp->data.u.str.area);
|
||||
/* SSL_get_peer_certificate increase X509 * ref count */
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
@ -6645,8 +6650,8 @@ smp_fetch_ssl_x_key_alg(const struct arg *args, struct sample *smp, const char *
|
||||
X509_PUBKEY_get0_param(&algorithm, NULL, NULL, NULL, X509_get_X509_PUBKEY(crt));
|
||||
nid = OBJ_obj2nid(algorithm);
|
||||
|
||||
smp->data.u.str.str = (char *)OBJ_nid2sn(nid);
|
||||
if (!smp->data.u.str.str) {
|
||||
smp->data.u.str.area = (char *)OBJ_nid2sn(nid);
|
||||
if (!smp->data.u.str.area) {
|
||||
/* SSL_get_peer_certificate increase X509 * ref count */
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
@ -6655,7 +6660,7 @@ smp_fetch_ssl_x_key_alg(const struct arg *args, struct sample *smp, const char *
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.u.str.len = strlen(smp->data.u.str.str);
|
||||
smp->data.u.str.data = strlen(smp->data.u.str.area);
|
||||
if (cert_peer)
|
||||
X509_free(crt);
|
||||
|
||||
@ -6726,13 +6731,13 @@ smp_fetch_ssl_fc_cipher(const struct arg *args, struct sample *smp, const char *
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str = (char *)SSL_get_cipher_name(conn->xprt_ctx);
|
||||
if (!smp->data.u.str.str)
|
||||
smp->data.u.str.area = (char *)SSL_get_cipher_name(conn->xprt_ctx);
|
||||
if (!smp->data.u.str.area)
|
||||
return 0;
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags |= SMP_F_CONST;
|
||||
smp->data.u.str.len = strlen(smp->data.u.str.str);
|
||||
smp->data.u.str.data = strlen(smp->data.u.str.area);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -6798,11 +6803,12 @@ smp_fetch_ssl_fc_npn(const struct arg *args, struct sample *smp, const char *kw,
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str = NULL;
|
||||
smp->data.u.str.area = NULL;
|
||||
SSL_get0_next_proto_negotiated(conn->xprt_ctx,
|
||||
(const unsigned char **)&smp->data.u.str.str, (unsigned *)&smp->data.u.str.len);
|
||||
(const unsigned char **)&smp->data.u.str.area,
|
||||
(unsigned *)&smp->data.u.str.data);
|
||||
|
||||
if (!smp->data.u.str.str)
|
||||
if (!smp->data.u.str.area)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -6822,11 +6828,12 @@ smp_fetch_ssl_fc_alpn(const struct arg *args, struct sample *smp, const char *kw
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str = NULL;
|
||||
smp->data.u.str.area = NULL;
|
||||
SSL_get0_alpn_selected(conn->xprt_ctx,
|
||||
(const unsigned char **)&smp->data.u.str.str, (unsigned *)&smp->data.u.str.len);
|
||||
(const unsigned char **)&smp->data.u.str.area,
|
||||
(unsigned *)&smp->data.u.str.data);
|
||||
|
||||
if (!smp->data.u.str.str)
|
||||
if (!smp->data.u.str.area)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -6847,13 +6854,13 @@ smp_fetch_ssl_fc_protocol(const struct arg *args, struct sample *smp, const char
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str = (char *)SSL_get_version(conn->xprt_ctx);
|
||||
if (!smp->data.u.str.str)
|
||||
smp->data.u.str.area = (char *)SSL_get_version(conn->xprt_ctx);
|
||||
if (!smp->data.u.str.area)
|
||||
return 0;
|
||||
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.u.str.len = strlen(smp->data.u.str.str);
|
||||
smp->data.u.str.data = strlen(smp->data.u.str.area);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -6880,8 +6887,9 @@ smp_fetch_ssl_fc_session_id(const struct arg *args, struct sample *smp, const ch
|
||||
if (!ssl_sess)
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str = (char *)SSL_SESSION_get_id(ssl_sess, (unsigned int *)&smp->data.u.str.len);
|
||||
if (!smp->data.u.str.str || !smp->data.u.str.len)
|
||||
smp->data.u.str.area = (char *)SSL_SESSION_get_id(ssl_sess,
|
||||
(unsigned int *)&smp->data.u.str.data);
|
||||
if (!smp->data.u.str.area || !smp->data.u.str.data)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -6906,8 +6914,10 @@ smp_fetch_ssl_fc_session_key(const struct arg *args, struct sample *smp, const c
|
||||
return 0;
|
||||
|
||||
data = get_trash_chunk();
|
||||
data->len = SSL_SESSION_get_master_key(ssl_sess, (unsigned char *)data->str, data->size);
|
||||
if (!data->len)
|
||||
data->data = SSL_SESSION_get_master_key(ssl_sess,
|
||||
(unsigned char *) data->area,
|
||||
data->size);
|
||||
if (!data->data)
|
||||
return 0;
|
||||
|
||||
smp->flags = 0;
|
||||
@ -6931,11 +6941,11 @@ smp_fetch_ssl_fc_sni(const struct arg *args, struct sample *smp, const char *kw,
|
||||
if (!conn || !conn->xprt_ctx || conn->xprt != &ssl_sock)
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.str = (char *)SSL_get_servername(conn->xprt_ctx, TLSEXT_NAMETYPE_host_name);
|
||||
if (!smp->data.u.str.str)
|
||||
smp->data.u.str.area = (char *)SSL_get_servername(conn->xprt_ctx, TLSEXT_NAMETYPE_host_name);
|
||||
if (!smp->data.u.str.area)
|
||||
return 0;
|
||||
|
||||
smp->data.u.str.len = strlen(smp->data.u.str.str);
|
||||
smp->data.u.str.data = strlen(smp->data.u.str.area);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@ -6956,8 +6966,8 @@ smp_fetch_ssl_fc_cl_bin(const struct arg *args, struct sample *smp, const char *
|
||||
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
smp->data.u.str.str = capture->ciphersuite;
|
||||
smp->data.u.str.len = capture->ciphersuite_len;
|
||||
smp->data.u.str.area = capture->ciphersuite;
|
||||
smp->data.u.str.data = capture->ciphersuite_len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -6970,7 +6980,7 @@ smp_fetch_ssl_fc_cl_hex(const struct arg *args, struct sample *smp, const char *
|
||||
return 0;
|
||||
|
||||
data = get_trash_chunk();
|
||||
dump_binary(data, smp->data.u.str.str, smp->data.u.str.len);
|
||||
dump_binary(data, smp->data.u.str.area, smp->data.u.str.data);
|
||||
smp->data.type = SMP_T_BIN;
|
||||
smp->data.u.str = *data;
|
||||
return 1;
|
||||
@ -7006,10 +7016,10 @@ smp_fetch_ssl_fc_cl_str(const struct arg *args, struct sample *smp, const char *
|
||||
return 0;
|
||||
|
||||
data = get_trash_chunk();
|
||||
for (i = 0; i + 1 < smp->data.u.str.len; i += 2) {
|
||||
for (i = 0; i + 1 < smp->data.u.str.data; i += 2) {
|
||||
const char *str;
|
||||
const SSL_CIPHER *cipher;
|
||||
const unsigned char *bin = (const unsigned char *)smp->data.u.str.str + i;
|
||||
const unsigned char *bin = (const unsigned char *) smp->data.u.str.area + i;
|
||||
uint16_t id = (bin[0] << 8) | bin[1];
|
||||
#if defined(OPENSSL_IS_BORINGSSL)
|
||||
cipher = SSL_get_cipher_by_value(id);
|
||||
@ -7051,14 +7061,18 @@ smp_fetch_ssl_fc_unique_id(const struct arg *args, struct sample *smp, const cha
|
||||
|
||||
finished_trash = get_trash_chunk();
|
||||
if (!SSL_session_reused(conn->xprt_ctx))
|
||||
finished_len = SSL_get_peer_finished(conn->xprt_ctx, finished_trash->str, finished_trash->size);
|
||||
finished_len = SSL_get_peer_finished(conn->xprt_ctx,
|
||||
finished_trash->area,
|
||||
finished_trash->size);
|
||||
else
|
||||
finished_len = SSL_get_finished(conn->xprt_ctx, finished_trash->str, finished_trash->size);
|
||||
finished_len = SSL_get_finished(conn->xprt_ctx,
|
||||
finished_trash->area,
|
||||
finished_trash->size);
|
||||
|
||||
if (!finished_len)
|
||||
return 0;
|
||||
|
||||
finished_trash->len = finished_len;
|
||||
finished_trash->data = finished_len;
|
||||
smp->data.u.str = *finished_trash;
|
||||
smp->data.type = SMP_T_BIN;
|
||||
|
||||
@ -8477,9 +8491,11 @@ static int cli_io_handler_tlskeys_files(struct appctx *appctx) {
|
||||
|
||||
chunk_reset(t2);
|
||||
/* should never fail here because we dump only a key in the t2 buffer */
|
||||
t2->len = a2base64((char *)(ref->tlskeys + (head + 2 + appctx->ctx.cli.i1) % TLS_TICKETS_NO),
|
||||
sizeof(struct tls_sess_key), t2->str, t2->size);
|
||||
chunk_appendf(&trash, "%d.%d %s\n", ref->unique_id, appctx->ctx.cli.i1, t2->str);
|
||||
t2->data = a2base64((char *)(ref->tlskeys + (head + 2 + appctx->ctx.cli.i1) % TLS_TICKETS_NO),
|
||||
sizeof(struct tls_sess_key),
|
||||
t2->area, t2->size);
|
||||
chunk_appendf(&trash, "%d.%d %s\n", ref->unique_id, appctx->ctx.cli.i1,
|
||||
t2->area);
|
||||
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
@ -8565,8 +8581,9 @@ static int cli_parse_set_tlskeys(char **args, char *payload, struct appctx *appc
|
||||
return 1;
|
||||
}
|
||||
|
||||
trash.len = base64dec(args[4], strlen(args[4]), trash.str, trash.size);
|
||||
if (trash.len != sizeof(struct tls_sess_key)) {
|
||||
trash.data = base64dec(args[4], strlen(args[4]), trash.area,
|
||||
trash.size);
|
||||
if (trash.data != sizeof(struct tls_sess_key)) {
|
||||
appctx->ctx.cli.severity = LOG_ERR;
|
||||
appctx->ctx.cli.msg = "'set ssl tls-key' received invalid base64 encoded TLS key.\n";
|
||||
appctx->st0 = CLI_ST_PRINT;
|
||||
@ -8606,8 +8623,8 @@ static int cli_parse_set_ocspresponse(char **args, char *payload, struct appctx
|
||||
}
|
||||
payload[j] = 0;
|
||||
|
||||
trash.len = base64dec(payload, j, trash.str, trash.size);
|
||||
if (trash.len < 0) {
|
||||
trash.data = base64dec(payload, j, trash.area, trash.size);
|
||||
if (trash.data < 0) {
|
||||
appctx->ctx.cli.severity = LOG_ERR;
|
||||
appctx->ctx.cli.msg = "'set ssl ocsp-response' received invalid base64 encoded response.\n";
|
||||
appctx->st0 = CLI_ST_PRINT;
|
||||
|
@ -1300,7 +1300,7 @@ int url2sa(const char *url, int ulen, struct sockaddr_storage *addr, struct spli
|
||||
return -1;
|
||||
|
||||
/* Look for ']' and copy the address in a trash buffer. */
|
||||
p = trash.str;
|
||||
p = trash.area;
|
||||
for (end = curr;
|
||||
end < url + ulen && *end != ']';
|
||||
end++, p++)
|
||||
@ -1316,7 +1316,7 @@ int url2sa(const char *url, int ulen, struct sockaddr_storage *addr, struct spli
|
||||
}
|
||||
|
||||
/* Try IPv6 decoding. */
|
||||
if (!inet_pton(AF_INET6, trash.str, &((struct sockaddr_in6 *)addr)->sin6_addr))
|
||||
if (!inet_pton(AF_INET6, trash.area, &((struct sockaddr_in6 *)addr)->sin6_addr))
|
||||
return -1;
|
||||
end++;
|
||||
|
||||
@ -1365,11 +1365,11 @@ int url2sa(const char *url, int ulen, struct sockaddr_storage *addr, struct spli
|
||||
for (end = curr;
|
||||
end < url + ulen && *end != '/' && *end != ':';
|
||||
end++);
|
||||
memcpy(trash.str, curr, end - curr);
|
||||
trash.str[end - curr] = '\0';
|
||||
memcpy(trash.area, curr, end - curr);
|
||||
trash.area[end - curr] = '\0';
|
||||
|
||||
/* try to resolve an IPv4/IPv6 hostname */
|
||||
he = gethostbyname(trash.str);
|
||||
he = gethostbyname(trash.area);
|
||||
if (!he)
|
||||
return -1;
|
||||
|
||||
@ -1557,8 +1557,8 @@ char *encode_chunk(char *start, char *stop,
|
||||
const char escape, const fd_set *map,
|
||||
const struct chunk *chunk)
|
||||
{
|
||||
char *str = chunk->str;
|
||||
char *end = chunk->str + chunk->len;
|
||||
char *str = chunk->area;
|
||||
char *end = chunk->area + chunk->data;
|
||||
|
||||
if (start < stop) {
|
||||
stop--; /* reserve one byte for the final '\0' */
|
||||
@ -1620,8 +1620,8 @@ char *escape_chunk(char *start, char *stop,
|
||||
const char escape, const fd_set *map,
|
||||
const struct chunk *chunk)
|
||||
{
|
||||
char *str = chunk->str;
|
||||
char *end = chunk->str + chunk->len;
|
||||
char *str = chunk->area;
|
||||
char *end = chunk->area + chunk->data;
|
||||
|
||||
if (start < stop) {
|
||||
stop--; /* reserve one byte for the final '\0' */
|
||||
@ -1672,8 +1672,8 @@ char *escape_chunk(char *start, char *stop,
|
||||
*/
|
||||
const char *csv_enc_append(const char *str, int quote, struct chunk *output)
|
||||
{
|
||||
char *end = output->str + output->size;
|
||||
char *out = output->str + output->len;
|
||||
char *end = output->area + output->size;
|
||||
char *out = output->area + output->data;
|
||||
char *ptr = out;
|
||||
|
||||
if (quote == 1) {
|
||||
@ -1703,7 +1703,7 @@ const char *csv_enc_append(const char *str, int quote, struct chunk *output)
|
||||
*ptr++ = '"';
|
||||
|
||||
*ptr = '\0';
|
||||
output->len = ptr - output->str;
|
||||
output->data = ptr - output->area;
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -3833,14 +3833,14 @@ int dump_text(struct chunk *out, const char *buf, int bsize)
|
||||
while (buf[ptr] && ptr < bsize) {
|
||||
c = buf[ptr];
|
||||
if (isprint(c) && isascii(c) && c != '\\' && c != ' ' && c != '=') {
|
||||
if (out->len > out->size - 1)
|
||||
if (out->data > out->size - 1)
|
||||
break;
|
||||
out->str[out->len++] = c;
|
||||
out->area[out->data++] = c;
|
||||
}
|
||||
else if (c == '\t' || c == '\n' || c == '\r' || c == '\e' || c == '\\' || c == ' ' || c == '=') {
|
||||
if (out->len > out->size - 2)
|
||||
if (out->data > out->size - 2)
|
||||
break;
|
||||
out->str[out->len++] = '\\';
|
||||
out->area[out->data++] = '\\';
|
||||
switch (c) {
|
||||
case ' ': c = ' '; break;
|
||||
case '\t': c = 't'; break;
|
||||
@ -3850,15 +3850,15 @@ int dump_text(struct chunk *out, const char *buf, int bsize)
|
||||
case '\\': c = '\\'; break;
|
||||
case '=': c = '='; break;
|
||||
}
|
||||
out->str[out->len++] = c;
|
||||
out->area[out->data++] = c;
|
||||
}
|
||||
else {
|
||||
if (out->len > out->size - 4)
|
||||
if (out->data > out->size - 4)
|
||||
break;
|
||||
out->str[out->len++] = '\\';
|
||||
out->str[out->len++] = 'x';
|
||||
out->str[out->len++] = hextab[(c >> 4) & 0xF];
|
||||
out->str[out->len++] = hextab[c & 0xF];
|
||||
out->area[out->data++] = '\\';
|
||||
out->area[out->data++] = 'x';
|
||||
out->area[out->data++] = hextab[(c >> 4) & 0xF];
|
||||
out->area[out->data++] = hextab[c & 0xF];
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
@ -3877,10 +3877,10 @@ int dump_binary(struct chunk *out, const char *buf, int bsize)
|
||||
while (ptr < bsize) {
|
||||
c = buf[ptr];
|
||||
|
||||
if (out->len > out->size - 2)
|
||||
if (out->data > out->size - 2)
|
||||
break;
|
||||
out->str[out->len++] = hextab[(c >> 4) & 0xF];
|
||||
out->str[out->len++] = hextab[c & 0xF];
|
||||
out->area[out->data++] = hextab[(c >> 4) & 0xF];
|
||||
out->area[out->data++] = hextab[c & 0xF];
|
||||
|
||||
ptr++;
|
||||
}
|
||||
@ -3901,7 +3901,7 @@ int dump_text_line(struct chunk *out, const char *buf, int bsize, int len,
|
||||
int end;
|
||||
unsigned char c;
|
||||
|
||||
end = out->len + 80;
|
||||
end = out->data + 80;
|
||||
if (end > out->size)
|
||||
return ptr;
|
||||
|
||||
@ -3910,13 +3910,13 @@ int dump_text_line(struct chunk *out, const char *buf, int bsize, int len,
|
||||
while (ptr < len && ptr < bsize) {
|
||||
c = buf[ptr];
|
||||
if (isprint(c) && isascii(c) && c != '\\') {
|
||||
if (out->len > end - 2)
|
||||
if (out->data > end - 2)
|
||||
break;
|
||||
out->str[out->len++] = c;
|
||||
out->area[out->data++] = c;
|
||||
} else if (c == '\t' || c == '\n' || c == '\r' || c == '\e' || c == '\\') {
|
||||
if (out->len > end - 3)
|
||||
if (out->data > end - 3)
|
||||
break;
|
||||
out->str[out->len++] = '\\';
|
||||
out->area[out->data++] = '\\';
|
||||
switch (c) {
|
||||
case '\t': c = 't'; break;
|
||||
case '\n': c = 'n'; break;
|
||||
@ -3924,24 +3924,24 @@ int dump_text_line(struct chunk *out, const char *buf, int bsize, int len,
|
||||
case '\e': c = 'e'; break;
|
||||
case '\\': c = '\\'; break;
|
||||
}
|
||||
out->str[out->len++] = c;
|
||||
out->area[out->data++] = c;
|
||||
} else {
|
||||
if (out->len > end - 5)
|
||||
if (out->data > end - 5)
|
||||
break;
|
||||
out->str[out->len++] = '\\';
|
||||
out->str[out->len++] = 'x';
|
||||
out->str[out->len++] = hextab[(c >> 4) & 0xF];
|
||||
out->str[out->len++] = hextab[c & 0xF];
|
||||
out->area[out->data++] = '\\';
|
||||
out->area[out->data++] = 'x';
|
||||
out->area[out->data++] = hextab[(c >> 4) & 0xF];
|
||||
out->area[out->data++] = hextab[c & 0xF];
|
||||
}
|
||||
if (buf[ptr++] == '\n') {
|
||||
/* we had a line break, let's return now */
|
||||
out->str[out->len++] = '\n';
|
||||
out->area[out->data++] = '\n';
|
||||
*line = ptr;
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
/* we have an incomplete line, we return it as-is */
|
||||
out->str[out->len++] = '\n';
|
||||
out->area[out->data++] = '\n';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
27
src/stats.c
27
src/stats.c
@ -343,10 +343,10 @@ int stats_emit_json_data_field(struct chunk *out, const struct field *f)
|
||||
break;
|
||||
}
|
||||
|
||||
old_len = out->len;
|
||||
old_len = out->data;
|
||||
chunk_appendf(out, ",\"value\":{\"type\":%s,\"value\":%s%s%s}",
|
||||
type, quote, value, quote);
|
||||
return !(old_len == out->len);
|
||||
return !(old_len == out->data);
|
||||
}
|
||||
|
||||
/* Emits an encoding of the field type on 3 characters followed by a delimiter.
|
||||
@ -433,13 +433,13 @@ int stats_emit_json_field_tags(struct chunk *out, const struct field *f)
|
||||
default: scope = "Unknown"; break;
|
||||
}
|
||||
|
||||
old_len = out->len;
|
||||
old_len = out->data;
|
||||
chunk_appendf(out, "\"tags\":{"
|
||||
"\"origin\":\"%s\","
|
||||
"\"nature\":\"%s\","
|
||||
"\"scope\":\"%s\""
|
||||
"}", origin, nature, scope);
|
||||
return !(old_len == out->len);
|
||||
return !(old_len == out->data);
|
||||
}
|
||||
|
||||
/* Dump all fields from <stats> into <out> using CSV format */
|
||||
@ -505,13 +505,13 @@ static int stats_dump_json_info_fields(struct chunk *out,
|
||||
goto err;
|
||||
started = 1;
|
||||
|
||||
old_len = out->len;
|
||||
old_len = out->data;
|
||||
chunk_appendf(out,
|
||||
"{\"field\":{\"pos\":%d,\"name\":\"%s\"},"
|
||||
"\"processNum\":%u,",
|
||||
field, info_field_names[field],
|
||||
info[INF_PROCESS_NUM].u.u32);
|
||||
if (old_len == out->len)
|
||||
if (old_len == out->data)
|
||||
goto err;
|
||||
|
||||
if (!stats_emit_json_field_tags(out, &info[field]))
|
||||
@ -565,7 +565,7 @@ static int stats_dump_fields_json(struct chunk *out, const struct field *stats,
|
||||
default: obj_type = "Unknown"; break;
|
||||
}
|
||||
|
||||
old_len = out->len;
|
||||
old_len = out->data;
|
||||
chunk_appendf(out,
|
||||
"{"
|
||||
"\"objType\":\"%s\","
|
||||
@ -576,7 +576,7 @@ static int stats_dump_fields_json(struct chunk *out, const struct field *stats,
|
||||
obj_type, stats[ST_F_IID].u.u32,
|
||||
stats[ST_F_SID].u.u32, field,
|
||||
stat_field_names[field], stats[ST_F_PID].u.u32);
|
||||
if (old_len == out->len)
|
||||
if (old_len == out->data)
|
||||
goto err;
|
||||
|
||||
if (!stats_emit_json_field_tags(out, &stats[field]))
|
||||
@ -2648,15 +2648,16 @@ static int stats_process_http_post(struct stream_interface *si)
|
||||
goto out;
|
||||
}
|
||||
|
||||
reql = co_getblk(si_oc(si), temp->str, s->txn->req.body_len, s->txn->req.eoh + 2);
|
||||
reql = co_getblk(si_oc(si), temp->area, s->txn->req.body_len,
|
||||
s->txn->req.eoh + 2);
|
||||
if (reql <= 0) {
|
||||
/* we need more data */
|
||||
appctx->ctx.stats.st_code = STAT_STATUS_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
first_param = temp->str;
|
||||
end_params = temp->str + reql;
|
||||
first_param = temp->area;
|
||||
end_params = temp->area + reql;
|
||||
cur_param = next_param = end_params;
|
||||
*end_params = '\0';
|
||||
|
||||
@ -3317,7 +3318,7 @@ static int stats_dump_info_to_buffer(struct stream_interface *si)
|
||||
static void stats_dump_json_schema(struct chunk *out)
|
||||
{
|
||||
|
||||
int old_len = out->len;
|
||||
int old_len = out->data;
|
||||
|
||||
chunk_strcat(out,
|
||||
"{"
|
||||
@ -3510,7 +3511,7 @@ static void stats_dump_json_schema(struct chunk *out)
|
||||
"}"
|
||||
"}");
|
||||
|
||||
if (old_len == out->len) {
|
||||
if (old_len == out->data) {
|
||||
chunk_reset(out);
|
||||
chunk_appendf(out,
|
||||
"{\"errorStr\":\"output buffer too short\"}");
|
||||
|
@ -697,12 +697,12 @@ struct stktable_key *smp_to_stkey(struct sample *smp, struct stktable *t)
|
||||
case SMP_T_STR:
|
||||
if (!smp_make_safe(smp))
|
||||
return NULL;
|
||||
static_table_key.key = smp->data.u.str.str;
|
||||
static_table_key.key_len = smp->data.u.str.len;
|
||||
static_table_key.key = smp->data.u.str.area;
|
||||
static_table_key.key_len = smp->data.u.str.data;
|
||||
break;
|
||||
|
||||
case SMP_T_BIN:
|
||||
if (smp->data.u.str.len < t->key_size) {
|
||||
if (smp->data.u.str.data < t->key_size) {
|
||||
/* This type needs padding with 0. */
|
||||
if (!smp_make_rw(smp))
|
||||
return NULL;
|
||||
@ -712,12 +712,12 @@ struct stktable_key *smp_to_stkey(struct sample *smp, struct stktable *t)
|
||||
return NULL;
|
||||
if (smp->data.u.str.size < t->key_size)
|
||||
return NULL;
|
||||
memset(smp->data.u.str.str + smp->data.u.str.len, 0,
|
||||
t->key_size - smp->data.u.str.len);
|
||||
smp->data.u.str.len = t->key_size;
|
||||
memset(smp->data.u.str.area + smp->data.u.str.data, 0,
|
||||
t->key_size - smp->data.u.str.data);
|
||||
smp->data.u.str.data = t->key_size;
|
||||
}
|
||||
static_table_key.key = smp->data.u.str.str;
|
||||
static_table_key.key_len = smp->data.u.str.len;
|
||||
static_table_key.key = smp->data.u.str.area;
|
||||
static_table_key.key_len = smp->data.u.str.data;
|
||||
break;
|
||||
|
||||
default: /* impossible case. */
|
||||
|
10
src/stream.c
10
src/stream.c
@ -1232,8 +1232,8 @@ static int process_switching_rules(struct stream *s, struct channel *req, int an
|
||||
if (!tmp)
|
||||
goto sw_failed;
|
||||
|
||||
if (build_logline(s, tmp->str, tmp->size, &rule->be.expr))
|
||||
backend = proxy_be_by_name(tmp->str);
|
||||
if (build_logline(s, tmp->area, tmp->size, &rule->be.expr))
|
||||
backend = proxy_be_by_name(tmp->area);
|
||||
|
||||
free_trash_chunk(tmp);
|
||||
tmp = NULL;
|
||||
@ -2381,7 +2381,7 @@ struct task *process_stream(struct task *t, void *context, unsigned short state)
|
||||
s->uniq_id, s->be->id,
|
||||
objt_cs(si_f->end) ? (unsigned short)objt_cs(si_f->end)->conn->handle.fd : -1,
|
||||
objt_cs(si_b->end) ? (unsigned short)objt_cs(si_b->end)->conn->handle.fd : -1);
|
||||
shut_your_big_mouth_gcc(write(1, trash.str, trash.len));
|
||||
shut_your_big_mouth_gcc(write(1, trash.area, trash.data));
|
||||
}
|
||||
|
||||
if (si_f->state == SI_ST_CLO &&
|
||||
@ -2390,7 +2390,7 @@ struct task *process_stream(struct task *t, void *context, unsigned short state)
|
||||
s->uniq_id, s->be->id,
|
||||
objt_cs(si_f->end) ? (unsigned short)objt_cs(si_f->end)->conn->handle.fd : -1,
|
||||
objt_cs(si_b->end) ? (unsigned short)objt_cs(si_b->end)->conn->handle.fd : -1);
|
||||
shut_your_big_mouth_gcc(write(1, trash.str, trash.len));
|
||||
shut_your_big_mouth_gcc(write(1, trash.area, trash.data));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2477,7 +2477,7 @@ struct task *process_stream(struct task *t, void *context, unsigned short state)
|
||||
s->uniq_id, s->be->id,
|
||||
objt_cs(si_f->end) ? (unsigned short)objt_cs(si_f->end)->conn->handle.fd : -1,
|
||||
objt_cs(si_b->end) ? (unsigned short)objt_cs(si_b->end)->conn->handle.fd : -1);
|
||||
shut_your_big_mouth_gcc(write(1, trash.str, trash.len));
|
||||
shut_your_big_mouth_gcc(write(1, trash.area, trash.data));
|
||||
}
|
||||
|
||||
s->logs.t_close = tv_ms_elapsed(&s->logs.tv_accept, &now);
|
||||
|
@ -143,8 +143,8 @@ void stream_int_retnclose(struct stream_interface *si, const struct chunk *msg)
|
||||
channel_erase(ic);
|
||||
channel_truncate(oc);
|
||||
|
||||
if (likely(msg && msg->len))
|
||||
co_inject(oc, msg->str, msg->len);
|
||||
if (likely(msg && msg->data))
|
||||
co_inject(oc, msg->area, msg->data);
|
||||
|
||||
oc->wex = tick_add_ifset(now_ms, oc->wto);
|
||||
channel_auto_read(oc);
|
||||
@ -354,7 +354,9 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
|
||||
if (conn->mux == &mux_pt_ops && cs->data_cb == &si_conn_cb) {
|
||||
struct stream_interface *si = cs->data;
|
||||
struct conn_stream *remote_cs = objt_cs(si_opposite(si)->end);
|
||||
ret = make_proxy_line(trash.str, trash.size, objt_server(conn->target), remote_cs ? remote_cs->conn : NULL);
|
||||
ret = make_proxy_line(trash.area, trash.size,
|
||||
objt_server(conn->target),
|
||||
remote_cs ? remote_cs->conn : NULL);
|
||||
}
|
||||
else {
|
||||
/* The target server expects a LOCAL line to be sent first. Retrieving
|
||||
@ -368,7 +370,8 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
|
||||
if (!(conn->flags & CO_FL_ADDR_TO_SET))
|
||||
goto out_wait;
|
||||
|
||||
ret = make_proxy_line(trash.str, trash.size, objt_server(conn->target), conn);
|
||||
ret = make_proxy_line(trash.area, trash.size,
|
||||
objt_server(conn->target), conn);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
@ -380,7 +383,9 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
|
||||
/* we have to send trash from (ret+sp for -sp bytes). If the
|
||||
* data layer has a pending write, we'll also set MSG_MORE.
|
||||
*/
|
||||
ret = conn_sock_send(conn, trash.str + ret + conn->send_proxy_ofs, -conn->send_proxy_ofs,
|
||||
ret = conn_sock_send(conn,
|
||||
trash.area + ret + conn->send_proxy_ofs,
|
||||
-conn->send_proxy_ofs,
|
||||
(conn->flags & CO_FL_XPRT_WR_ENA) ? MSG_MORE : 0);
|
||||
|
||||
if (ret < 0)
|
||||
|
@ -219,11 +219,12 @@ resume_execution:
|
||||
if (cap[h->index] == NULL) /* no more capture memory */
|
||||
continue;
|
||||
|
||||
len = key->data.u.str.len;
|
||||
len = key->data.u.str.data;
|
||||
if (len > h->len)
|
||||
len = h->len;
|
||||
|
||||
memcpy(cap[h->index], key->data.u.str.str, len);
|
||||
memcpy(cap[h->index], key->data.u.str.area,
|
||||
len);
|
||||
cap[h->index][len] = 0;
|
||||
}
|
||||
else {
|
||||
@ -600,7 +601,8 @@ static int tcp_parse_response_rule(char **args, int arg, int section_type,
|
||||
action_build_list(&tcp_res_cont_keywords, &trash);
|
||||
memprintf(err,
|
||||
"'%s %s' expects 'accept', 'close', 'reject', %s in %s '%s' (got '%s')",
|
||||
args[0], args[1], trash.str, proxy_type_str(curpx), curpx->id, args[arg]);
|
||||
args[0], args[1], trash.area,
|
||||
proxy_type_str(curpx), curpx->id, args[arg]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -849,7 +851,8 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
|
||||
memprintf(err,
|
||||
"'%s %s' expects 'accept', 'reject', 'track-sc0' ... 'track-sc%d', %s "
|
||||
"in %s '%s' (got '%s').\n",
|
||||
args[0], args[1], MAX_SESS_STKCTR-1, trash.str, proxy_type_str(curpx),
|
||||
args[0], args[1], MAX_SESS_STKCTR-1,
|
||||
trash.area, proxy_type_str(curpx),
|
||||
curpx->id, args[arg]);
|
||||
return -1;
|
||||
}
|
||||
|
52
src/vars.c
52
src/vars.c
@ -95,12 +95,12 @@ unsigned int var_clear(struct var *var)
|
||||
unsigned int size = 0;
|
||||
|
||||
if (var->data.type == SMP_T_STR || var->data.type == SMP_T_BIN) {
|
||||
free(var->data.u.str.str);
|
||||
size += var->data.u.str.len;
|
||||
free(var->data.u.str.area);
|
||||
size += var->data.u.str.data;
|
||||
}
|
||||
else if (var->data.type == SMP_T_METH && var->data.u.meth.meth == HTTP_METH_OTHER) {
|
||||
free(var->data.u.meth.str.str);
|
||||
size += var->data.u.meth.str.len;
|
||||
free(var->data.u.meth.str.area);
|
||||
size += var->data.u.meth.str.data;
|
||||
}
|
||||
LIST_DEL(&var->l);
|
||||
pool_free(var_pool, var);
|
||||
@ -343,12 +343,14 @@ static int sample_store(struct vars *vars, const char *name, struct sample *smp)
|
||||
/* free its used memory. */
|
||||
if (var->data.type == SMP_T_STR ||
|
||||
var->data.type == SMP_T_BIN) {
|
||||
free(var->data.u.str.str);
|
||||
var_accounting_diff(vars, smp->sess, smp->strm, -var->data.u.str.len);
|
||||
free(var->data.u.str.area);
|
||||
var_accounting_diff(vars, smp->sess, smp->strm,
|
||||
-var->data.u.str.data);
|
||||
}
|
||||
else if (var->data.type == SMP_T_METH && var->data.u.meth.meth == HTTP_METH_OTHER) {
|
||||
free(var->data.u.meth.str.str);
|
||||
var_accounting_diff(vars, smp->sess, smp->strm, -var->data.u.meth.str.len);
|
||||
free(var->data.u.meth.str.area);
|
||||
var_accounting_diff(vars, smp->sess, smp->strm,
|
||||
-var->data.u.meth.str.data);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -381,37 +383,41 @@ static int sample_store(struct vars *vars, const char *name, struct sample *smp)
|
||||
break;
|
||||
case SMP_T_STR:
|
||||
case SMP_T_BIN:
|
||||
if (!var_accounting_add(vars, smp->sess, smp->strm, smp->data.u.str.len)) {
|
||||
if (!var_accounting_add(vars, smp->sess, smp->strm, smp->data.u.str.data)) {
|
||||
var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */
|
||||
return 0;
|
||||
}
|
||||
var->data.u.str.str = malloc(smp->data.u.str.len);
|
||||
if (!var->data.u.str.str) {
|
||||
var_accounting_diff(vars, smp->sess, smp->strm, -smp->data.u.str.len);
|
||||
var->data.u.str.area = malloc(smp->data.u.str.data);
|
||||
if (!var->data.u.str.area) {
|
||||
var_accounting_diff(vars, smp->sess, smp->strm,
|
||||
-smp->data.u.str.data);
|
||||
var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */
|
||||
return 0;
|
||||
}
|
||||
var->data.u.str.len = smp->data.u.str.len;
|
||||
memcpy(var->data.u.str.str, smp->data.u.str.str, var->data.u.str.len);
|
||||
var->data.u.str.data = smp->data.u.str.data;
|
||||
memcpy(var->data.u.str.area, smp->data.u.str.area,
|
||||
var->data.u.str.data);
|
||||
break;
|
||||
case SMP_T_METH:
|
||||
var->data.u.meth.meth = smp->data.u.meth.meth;
|
||||
if (smp->data.u.meth.meth != HTTP_METH_OTHER)
|
||||
break;
|
||||
|
||||
if (!var_accounting_add(vars, smp->sess, smp->strm, smp->data.u.meth.str.len)) {
|
||||
if (!var_accounting_add(vars, smp->sess, smp->strm, smp->data.u.meth.str.data)) {
|
||||
var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */
|
||||
return 0;
|
||||
}
|
||||
var->data.u.meth.str.str = malloc(smp->data.u.meth.str.len);
|
||||
if (!var->data.u.meth.str.str) {
|
||||
var_accounting_diff(vars, smp->sess, smp->strm, -smp->data.u.meth.str.len);
|
||||
var->data.u.meth.str.area = malloc(smp->data.u.meth.str.data);
|
||||
if (!var->data.u.meth.str.area) {
|
||||
var_accounting_diff(vars, smp->sess, smp->strm,
|
||||
-smp->data.u.meth.str.data);
|
||||
var->data.type = SMP_T_BOOL; /* This type doesn't use additional memory. */
|
||||
return 0;
|
||||
}
|
||||
var->data.u.meth.str.len = smp->data.u.meth.str.len;
|
||||
var->data.u.meth.str.size = smp->data.u.meth.str.len;
|
||||
memcpy(var->data.u.meth.str.str, smp->data.u.meth.str.str, var->data.u.meth.str.len);
|
||||
var->data.u.meth.str.data = smp->data.u.meth.str.data;
|
||||
var->data.u.meth.str.size = smp->data.u.meth.str.data;
|
||||
memcpy(var->data.u.meth.str.area, smp->data.u.meth.str.area,
|
||||
var->data.u.meth.str.data);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
@ -497,7 +503,9 @@ int vars_check_arg(struct arg *arg, char **err)
|
||||
}
|
||||
|
||||
/* Register new variable name. */
|
||||
name = register_name(arg->data.str.str, arg->data.str.len, &scope, 1, err);
|
||||
name = register_name(arg->data.str.area, arg->data.str.data, &scope,
|
||||
1,
|
||||
err);
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
|
15
src/wurfl.c
15
src/wurfl.c
@ -576,8 +576,8 @@ static int ha_wurfl_get_all(const struct arg *args, struct sample *smp, const ch
|
||||
}
|
||||
|
||||
wurfl_device_destroy(dHandle);
|
||||
smp->data.u.str.str = temp->str;
|
||||
smp->data.u.str.len = temp->len;
|
||||
smp->data.u.str.area = temp->area;
|
||||
smp->data.u.str.data = temp->data;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -602,9 +602,9 @@ static int ha_wurfl_get(const struct arg *args, struct sample *smp, const char *
|
||||
temp = get_trash_chunk();
|
||||
chunk_reset(temp);
|
||||
|
||||
while (args[i].data.str.str) {
|
||||
while (args[i].data.str.area) {
|
||||
chunk_appendf(temp, "%c", global_wurfl.information_list_separator);
|
||||
node = ebst_lookup(&global_wurfl.btree, args[i].data.str.str);
|
||||
node = ebst_lookup(&global_wurfl.btree, args[i].data.str.area);
|
||||
wn = container_of(node, wurfl_data_t, nd);
|
||||
|
||||
if (wn) {
|
||||
@ -644,15 +644,16 @@ static int ha_wurfl_get(const struct arg *args, struct sample *smp, const char *
|
||||
}
|
||||
|
||||
} else {
|
||||
ha_wurfl_log("WURFL: %s not in wurfl-information-list \n", args[i].data.str.str);
|
||||
ha_wurfl_log("WURFL: %s not in wurfl-information-list \n",
|
||||
args[i].data.str.area);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
wurfl_device_destroy(dHandle);
|
||||
smp->data.u.str.str = temp->str;
|
||||
smp->data.u.str.len = temp->len;
|
||||
smp->data.u.str.area = temp->area;
|
||||
smp->data.u.str.data = temp->data;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user