This is an automated email from the ASF dual-hosted git repository.
dmeden 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 bbe73d6a5a TS API: Txn config string set. Add nullptr check for
default var string set. (#10135)
bbe73d6a5a is described below
commit bbe73d6a5aa965265f47944719499d954c83628f
Author: Damian Meden <[email protected]>
AuthorDate: Thu Aug 3 14:28:12 2023 +0200
TS API: Txn config string set. Add nullptr check for default var string
set. (#10135)
Without this we will try to store a null ptr which will cause a crash.
---
src/traffic_server/InkAPI.cc | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc
index 3ad360b06a..7ee1d8f45e 100644
--- a/src/traffic_server/InkAPI.cc
+++ b/src/traffic_server/InkAPI.cc
@@ -8940,12 +8940,14 @@ TSHttpTxnConfigStringSet(TSHttpTxn txnp,
TSOverridableConfigKey conf, const char
}
[[fallthrough]];
default: {
- MgmtConverter const *conv;
- void *dest = _conf_to_memberp(conf, &(s->t_state.my_txn_conf()), conv);
- if (dest != nullptr && conv != nullptr && conv->store_string) {
- conv->store_string(dest, std::string_view(value, length));
- } else {
- return TS_ERROR;
+ if (value && length > 0) {
+ MgmtConverter const *conv;
+ void *dest = _conf_to_memberp(conf, &(s->t_state.my_txn_conf()), conv);
+ if (dest != nullptr && conv != nullptr && conv->store_string) {
+ conv->store_string(dest, std::string_view(value, length));
+ } else {
+ return TS_ERROR;
+ }
}
break;
}