From bf9c50fbeb2f4c8e1adcb984475109c208ea3083 Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Wed, 8 Dec 2021 17:35:17 +0000 Subject: [PATCH] combo_handler: Initialize User Arg Index in TSRemapInit 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. --- 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 576dcee0ee4..d8b9ec09900 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 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;