Skip to content

Commit 9399a76

Browse files
committed
TS-3841: LogAccess.cc assert failed when enabling custom log and stats_over_http plugin
1 parent 4c65b77 commit 9399a76

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

proxy/logging/LogAccessHttp.cc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,16 +506,29 @@ LogAccessHttp::marshal_client_req_unmapped_url_path(char *buf)
506506
int
507507
LogAccessHttp::marshal_client_req_unmapped_url_host(char *buf)
508508
{
509-
int len = INK_MIN_ALIGN;
509+
int plen = INK_MIN_ALIGN;
510510

511511
validate_unmapped_url();
512512
validate_unmapped_url_path();
513513

514-
len = round_strlen(m_client_req_unmapped_url_host_len + 1); // +1 for eos
514+
int alen = m_client_req_unmapped_url_host_len;
515+
if (alen < 0) {
516+
alen = 0;
517+
}
518+
519+
// calculate the the padded length only if the actual length
520+
// is not zero. We don't want the padded length to be zero
521+
// because marshal_mem should write the DEFAULT_STR to the
522+
// buffer if str is nil, and we need room for this.
523+
if (alen) {
524+
plen = round_strlen(alen + 1); // +1 for eos
525+
}
526+
515527
if (buf) {
516-
marshal_mem(buf, m_client_req_unmapped_url_host_str, m_client_req_unmapped_url_host_len, len);
528+
marshal_mem(buf, m_client_req_unmapped_url_host_str, alen, plen);
517529
}
518-
return len;
530+
531+
return plen;
519532
}
520533

521534
int

0 commit comments

Comments
 (0)