hnakamur commented on code in PR #12091:
URL: https://github.com/apache/trafficserver/pull/12091#discussion_r2022747552
##########
src/iocore/cache/CacheVC.cc:
##########
@@ -775,7 +775,9 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /*
e ATS_UNUSED */)
goto Lskip;
}
if (!hostinfo_copied) {
- memccpy(hname, vector.get(i)->request_get()->host_get(&hlen), 0, 500);
+ auto host{vector.get(i)->request_get()->host_get()};
+ hlen = static_cast<int>(host.length());
+ memccpy(hname, host.data(), 0, 500);
Review Comment:
I suppose the size of `hname` (500 bytes) is large enough since the max
length of hostnames is 255 bytes according to
https://www.rfc-editor.org/rfc/rfc1035.html#section-2.3.4.
So I think it's safe to assume that `hname` is null terminated.
Or how about using `ink_strlcpy` instead to be sure?
We need to copy `host` to `hname` as it will be used after elements in
`vector` are deleted.
We could use `std::string` or `ats_scoped_str` for backstore, but I think we
would like to avoid a heap allocation if possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]