bryancall commented on code in PR #13030:
URL: https://github.com/apache/trafficserver/pull/13030#discussion_r2999344506
##########
src/proxy/IPAllow.cc:
##########
@@ -243,6 +243,7 @@ IpAllow::IpAllow(const char *ip_allow_config_var, const
char *ip_categories_conf
std::string_view subject_sv = subjects_sv.substr(s, e);
Review Comment:
Fixed. Changed to `subjects_sv.substr(s, e == subjects_sv.npos ?
subjects_sv.npos : e - s)` so the extracted token length is correct for middle
tokens.
##########
src/proxy/IPAllow.cc:
##########
@@ -243,6 +243,7 @@ IpAllow::IpAllow(const char *ip_allow_config_var, const
char *ip_categories_conf
std::string_view subject_sv = subjects_sv.substr(s, e);
if (i >= MAX_SUBJECTS) {
Error("Too many ACL subjects were provided");
+ break;
Review Comment:
Added `ip_allow_subjects.test.py` which tests both the overflow case (4
subjects, verifies error is logged and ATS doesn't crash) and the normal case
(3 subjects, verifies no error).
##########
plugins/slice/server.cc:
##########
@@ -463,14 +464,19 @@ handleNextServerHeader(Data *const data)
data->m_blockstate = BlockState::PendingRef;
// interior headers for new identifier reference
+ etaglen = std::min(etaglen,
static_cast<int>(sizeof(data->m_etag) - 1));
data->m_etaglen = etaglen;
if (0 < etaglen) {
- strncpy(data->m_etag, etag, etaglen);
+ memcpy(data->m_etag, etag, etaglen);
}
+ data->m_etag[etaglen] = '\0';
+
+ lastmodifiedlen = std::min(lastmodifiedlen,
static_cast<int>(sizeof(data->m_lastmodified) - 1));
data->m_lastmodifiedlen = lastmodifiedlen;
if (0 < lastmodifiedlen) {
- strncpy(data->m_lastmodified, lastmodified, lastmodifiedlen);
+ memcpy(data->m_lastmodified, lastmodified, lastmodifiedlen);
}
+ data->m_lastmodified[lastmodifiedlen] = '\0';
Review Comment:
Added `slice_long_etag.test.py` which tests a 4000-character ETag through
multi-block slice requests to exercise the truncation and null-termination path.
--
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]