You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2022/01/05 20:09:57 UTC

[trafficserver] branch 9.2.x updated: combo_handler: Initialize User Arg Index in TSRemapInit (#8551)

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

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 3cd3f3b  combo_handler: Initialize User Arg Index in TSRemapInit (#8551)
3cd3f3b is described below

commit 3cd3f3b8f6b5519d309fbc91f2b0b8d0eb90b613
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Thu Dec 9 11:09:15 2021 -0600

    combo_handler: Initialize User Arg Index in TSRemapInit (#8551)
    
    The combo_handler plugin did not register its transaction argument index
    in TSRemapInit, which resulted in using an unregistered id. This
    generally meant it indexed 0, which could result in it accessing the
    wrong plugin's transaction user argument data.
    
    (cherry picked from commit ed81c934797a9f1da7af1790aa3e3c4ac265e445)
---
 plugins/esi/combo_handler.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/plugins/esi/combo_handler.cc b/plugins/esi/combo_handler.cc
index 576dcee..d8b9ec0 100644
--- a/plugins/esi/combo_handler.cc
+++ b/plugins/esi/combo_handler.cc
@@ -63,7 +63,7 @@ unsigned MaxFileCount = DEFAULT_MAX_FILE_COUNT;
 // We hardcode "immutable" here because it's not yet defined in the ATS API
 #define HTTP_IMMUTABLE "immutable"
 
-int arg_idx;
+int arg_idx = -1;
 static string SIG_KEY_NAME;
 static vector<string> HEADER_ALLOWLIST;
 
@@ -1236,6 +1236,13 @@ TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
     return TS_ERROR;
   }
 
+  if (TSUserArgIndexReserve(TS_USER_ARGS_TXN, DEBUG_TAG, "will save plugin-enable flag here", &arg_idx) != TS_SUCCESS) {
+    LOG_ERROR("failed to reserve private data slot");
+    return TS_ERROR;
+  } else {
+    LOG_DEBUG("txn_arg_idx: %d", arg_idx);
+  }
+
   TSDebug(DEBUG_TAG, "%s plugin's remap part is initialized", DEBUG_TAG);
 
   return TS_SUCCESS;