mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 02:56:51 +00:00
BUG/MEDIUM: unique_id: junk in log on empty unique_id
When a request fail, the unique_id was allocated but not generated. The string was not initialized and junk was printed in the log with %ID. This patch changes the behavior of the unique_id. The unique_id is now generated when a request failed. This bug was reported by Patrick Hemmer.
This commit is contained in:
parent
9f09521f2d
commit
5b7ea3afa1
10
src/log.c
10
src/log.c
@ -1488,8 +1488,10 @@ int build_logline(struct session *s, char *dst, size_t maxsize, struct list *lis
|
||||
break;
|
||||
|
||||
case LOG_FMT_UNIQUEID: // %ID
|
||||
ret = NULL;
|
||||
src = s->unique_id;
|
||||
ret = lf_text(tmplog, src, maxsize - (tmplog - dst), tmp);
|
||||
if (src)
|
||||
ret = lf_text(tmplog, src, maxsize - (tmplog - dst), tmp);
|
||||
if (ret == NULL)
|
||||
goto out;
|
||||
tmplog = ret;
|
||||
@ -1541,6 +1543,12 @@ void sess_log(struct session *s)
|
||||
level = LOG_ERR;
|
||||
}
|
||||
|
||||
/* if unique-id was not generated */
|
||||
if (!s->unique_id && !LIST_ISEMPTY(&s->fe->format_unique_id)) {
|
||||
if ((s->unique_id = pool_alloc2(pool2_uniqueid)) != NULL)
|
||||
build_logline(s, s->unique_id, UNIQUEID_LEN, &s->fe->format_unique_id);
|
||||
}
|
||||
|
||||
tmplog = update_log_hdr();
|
||||
size = tmplog - logline;
|
||||
size += build_logline(s, tmplog, sizeof(logline) - size, &s->fe->logformat);
|
||||
|
@ -2635,9 +2635,6 @@ int http_wait_for_request(struct session *s, struct channel *req, int an_bit)
|
||||
}
|
||||
}
|
||||
|
||||
if (!LIST_ISEMPTY(&s->fe->format_unique_id))
|
||||
s->unique_id = pool_alloc2(pool2_uniqueid);
|
||||
|
||||
/* 4. We may have to convert HTTP/0.9 requests to HTTP/1.0 */
|
||||
if (unlikely(msg->sl.rq.v_l == 0) && !http_upgrade_v09_to_v10(txn))
|
||||
goto return_bad_req;
|
||||
@ -3950,8 +3947,12 @@ int http_process_request(struct session *s, struct channel *req, int an_bit)
|
||||
|
||||
/* add unique-id if "header-unique-id" is specified */
|
||||
|
||||
if (!LIST_ISEMPTY(&s->fe->format_unique_id))
|
||||
if (!LIST_ISEMPTY(&s->fe->format_unique_id)) {
|
||||
if ((s->unique_id = pool_alloc2(pool2_uniqueid)) == NULL)
|
||||
goto return_bad_req;
|
||||
s->unique_id[0] = '\0';
|
||||
build_logline(s, s->unique_id, UNIQUEID_LEN, &s->fe->format_unique_id);
|
||||
}
|
||||
|
||||
if (s->fe->header_unique_id && s->unique_id) {
|
||||
chunk_printf(&trash, "%s: %s", s->fe->header_unique_id, s->unique_id);
|
||||
|
Loading…
Reference in New Issue
Block a user