This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 8d5482854d stek_share: resize instead of reserve (#10793)
8d5482854d is described below

commit 8d5482854d0ab25811e55ceef359eeede0f7a07d
Author: Brian Neradt <brian.ner...@gmail.com>
AuthorDate: Wed Nov 15 17:18:48 2023 -0600

    stek_share: resize instead of reserve (#10793)
    
    stek_share indexes into an offset on a string that it reserved space
    for, but indexing past size() is undefined behavior. This would result
    in crashing on some systems. reszing adjusts the length which satisfies
    the indexing requirement.
---
 plugins/experimental/stek_share/common.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/experimental/stek_share/common.cc 
b/plugins/experimental/stek_share/common.cc
index b9af195e70..c2cd21c865 100644
--- a/plugins/experimental/stek_share/common.cc
+++ b/plugins/experimental/stek_share/common.cc
@@ -36,7 +36,7 @@ std::string
 hex_str(std::string const &str)
 {
   std::string hex_str;
-  hex_str.reserve(str.size() * 2);
+  hex_str.resize(str.size() * 2);
   for (unsigned long int i = 0; i < str.size(); ++i) {
     unsigned char c    = str.at(i);
     hex_str[i * 2]     = hex_chars[(c & 0xF0) >> 4];

Reply via email to