serrislew commented on code in PR #13968:
URL: https://github.com/apache/trafficserver/pull/13968#discussion_r4529671985


##########
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:
   This does fix the memory-safety bug, but the failure is silent. A cleaner 
fix would be to build the new query in a std::string, which has no size limit. 
Otherwise, consider logging or returning an error



-- 
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]

Reply via email to