SABITHSAHEB commented on code in PR #13968:
URL: https://github.com/apache/trafficserver/pull/13968#discussion_r4577508842
##########
plugins/experimental/mp4/mp4.cc:
##########
@@ -123,6 +123,11 @@ TSRemapDoRemap(void * /* ih ATS_UNUSED */, TSHttpTxn rh,
TSRemapRequestInfo *rri
}
buf_len = snprintf(buf, sizeof(buf), "%.*s%.*s", left, query, right, query +
query_len - right);
+ if (buf_len < 0 || buf_len >= static_cast<int>(sizeof(buf))) {
+ // snprintf returns the length it would have written, so on truncation
buf_len
+ // exceeds buf; using it as the copy length reads past the stack buffer.
+ return TSREMAP_NO_REMAP;
Review Comment:
Agreed, bailing out meant long queries quietly kept the start argument.
Switched to building the query in a std::string in 83fc7ce, so there's no size
limit and the rewrite always happens. Checked it under ASan with queries up to
32 KB and the output is correct with no out-of-bounds reads.
##########
plugins/experimental/mp4/mp4.cc:
##########
@@ -123,6 +123,11 @@ TSRemapDoRemap(void * /* ih ATS_UNUSED */, TSHttpTxn rh,
TSRemapRequestInfo *rri
}
buf_len = snprintf(buf, sizeof(buf), "%.*s%.*s", left, query, right, query +
query_len - right);
+ if (buf_len < 0 || buf_len >= static_cast<int>(sizeof(buf))) {
Review Comment:
The std::string rewrite (83fc7ce) removes the fixed buffer and the int
length check, so this one doesn't apply anymore.
--
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]