[
https://issues.apache.org/jira/browse/TS-3222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14252770#comment-14252770
]
Nakagome Tomoyuki commented on TS-3222:
---------------------------------------
We've applied the suggested fix (snprintf instead of sprintf) in 3.2.0 codeline
that we use with out product.
1. snprintf() do not write more than the "size" (second argument).
2. There will be no space in port_buff when snprintf completes. If input is
www.apache.org:80, port_buff will be
{noformat}'8' '0' '\0'{noformat}
and generated URL will be like
{noformat}http://www.apache.org:80/xyz.html{noformat}
That seems much better than zero padding the port number.
> Port number padded with 0 when Host header has explicit port specification
> --------------------------------------------------------------------------
>
> Key: TS-3222
> URL: https://issues.apache.org/jira/browse/TS-3222
> Project: Traffic Server
> Issue Type: Bug
> Reporter: Nakagome Tomoyuki
> Assignee: Alan M. Carroll
> Fix For: 5.3.0
>
>
> Due to this line in proxy/hdrs/HTTP.cc:1552
> {noformat}
> ui->m_len_port = sprintf(port_buff, "%.5d", hdr->m_port);
> {noformat}
> UrlPrintHack::UrlPrintHack() prepends unnecessary '0's so the port_buff will
> be 5 chars, like "00080". Suggestion is to remove .5 from the format string
> and change it to
> {noformat}
> ui->m_len_port = snprintf(port_buff, 6, "%d", hdr->m_port);
> {noformat}
> unless there are some specific reasons for the current code.
> To replicate the symptom, send a request with a Host header having a port
> number like:
> Host: www.apache.org:80
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)