Commit c4752004 authored by Geoff Simmons's avatar Geoff Simmons

varnishevent - check against exceeding max_headers

parent a1da0e1d
......@@ -100,12 +100,8 @@ typedef struct fd_t {
static fd_t *fd_tbl;
static unsigned seen = 0;
static unsigned open = 0;
static unsigned submitted = 0;
static unsigned occ_hi = 0;
static unsigned waits = 0;
static unsigned len_overflows = 0;
static unsigned seen = 0, open = 0, submitted = 0, occ_hi = 0, waits = 0,
len_overflows = 0, hdr_overflows = 0;
static volatile sig_atomic_t reopen;
......@@ -132,10 +128,11 @@ void
RDR_Stats(void)
{
LOG_Log(LOG_INFO, "Reader (%s): fd_max=%u seen=%u open=%u load=%.2f "
"submitted=%u occ_hi=%u waits=%u free=%u len_overflows=%u",
"submitted=%u occ_hi=%u waits=%u free=%u len_overflows=%u "
"hdr_overflows=%u",
waiting ? "waiting" : "running", config.max_fd, seen, open,
100.0 * open / config.max_fd, submitted, occ_hi, waits, rdr_free,
len_overflows);
len_overflows, hdr_overflows);
}
static inline logline_t
......@@ -180,8 +177,8 @@ static inline void
collect(struct logline_t *lp, enum VSL_tag_e tag, unsigned spec,
const char *ptr, unsigned len)
{
char *dest;
unsigned *llen;
hdr_t *hdr = NULL;
record_t *rec = NULL;
if (spec & VSL_S_BACKEND || spec & VSL_S_CLIENT) {
if (!lp->spec)
......@@ -191,32 +188,36 @@ collect(struct logline_t *lp, enum VSL_tag_e tag, unsigned spec,
}
if (len > config.max_reclen) {
LOG_Log(LOG_ALERT, "Data length %u exceeds max %u [%.*s]", len,
config.max_reclen, len, ptr);
LOG_Log(LOG_ALERT,
"Data length %u exceeds max %u, DATA TRUNCATED: %s [%.*s]",
len, config.max_reclen, VSL_tags[tag], len, ptr);
len_overflows++;
len = config.max_reclen;
}
/* XXX: check against overflow for lp->nrec */
if (tag == SLT_RxHeader) {
dest = lp->rx_headers.record[lp->rx_headers.nrec].data;
llen = &lp->rx_headers.record[lp->rx_headers.nrec++].len;
}
else if (tag == SLT_TxHeader) {
dest = lp->tx_headers.record[lp->tx_headers.nrec].data;
llen = &lp->tx_headers.record[lp->tx_headers.nrec++].len;
}
else if (tag == SLT_VCL_Log) {
dest = lp->vcl_log.record[lp->vcl_log.nrec].data;
llen = &lp->vcl_log.record[lp->vcl_log.nrec++].len;
}
else {
dest = lp->tag[tag].data;
llen = &lp->tag[tag].len;
if (tag == SLT_RxHeader)
hdr = &lp->rx_headers;
else if (tag == SLT_TxHeader)
hdr = &lp->tx_headers;
else if (tag == SLT_VCL_Log)
hdr = &lp->vcl_log;
if (hdr != NULL) {
if (hdr->nrec < config.max_headers)
rec = &hdr->record[hdr->nrec++];
else {
LOG_Log(LOG_ALERT,
"Number of headers exceeds max %u, DATA DISCARDED: %s [%.*s]",
config.max_headers, VSL_tags[tag], len, ptr);
hdr_overflows++;
return;
}
}
else
rec = &lp->tag[tag];
memcpy(dest, ptr, len);
*llen = len;
memcpy(rec->data, ptr, len);
rec->len = len;
switch (tag) {
case SLT_BackendReuse:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment