cmcfarlen commented on code in PR #12634:
URL: https://github.com/apache/trafficserver/pull/12634#discussion_r2487560615


##########
plugins/stats_over_http/stats_over_http.cc:
##########
@@ -804,7 +804,17 @@ stats_origin(TSCont contp, TSEvent /* event ATS_UNUSED */, 
void *edata)
   my_state->encoding    = encoding_format_t::NONE;
   if (accept_encoding_field != TS_NULL_MLOC) {
     int         len = -1;
-    const char *str = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, 
accept_encoding_field, -1, &len);
+    const char *mime_str = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, 
accept_encoding_field, -1, &len);
+    char       *str = nullptr;
+
+    // Ensure str is null-terminated for strstr()
+    if (len > 0) {
+      str = TSstrndup(mime_str, len);

Review Comment:
   Instead of this, could you create a std::string_view from `{mime_str, Len}` 
and use `std::string_view::find` to search for the string?



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