Skip to content

Commit f792cd7

Browse files
authored
header_rewrite: Fix uninitialized bufp/hdr_loc (#12520)
Fix a bug where if RSRC_RESPONSE_STATUS is requested without RSRC_SERVER_RESPONSE_HEADERS, the bufp and hdr_loc variables would be uninitialized when passed to TSHttpHdrStatusGet(). This change ensures that TSHttpTxnServerRespGet() is called when either resource is requested, properly initializing the required variables.
1 parent 2128398 commit f792cd7

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

plugins/header_rewrite/resources.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ Resources::gather(const ResourceIDs ids, TSHttpHookID hook)
5252
switch (hook) {
5353
case TS_HTTP_READ_RESPONSE_HDR_HOOK:
5454
// Read response headers from server
55-
if (ids & RSRC_SERVER_RESPONSE_HEADERS) {
55+
if ((ids & RSRC_SERVER_RESPONSE_HEADERS) || (ids & RSRC_RESPONSE_STATUS)) {
5656
Dbg(pi_dbg_ctl, "\tAdding TXN server response header buffers");
5757
if (TSHttpTxnServerRespGet(state.txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
5858
Dbg(pi_dbg_ctl, "could not gather bufp/hdr_loc for response");
5959
return;
6060
}
61-
}
62-
if (ids & RSRC_RESPONSE_STATUS) {
63-
Dbg(pi_dbg_ctl, "\tAdding TXN server response status resource");
64-
resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
61+
if (ids & RSRC_RESPONSE_STATUS) {
62+
Dbg(pi_dbg_ctl, "\tAdding TXN server response status resource");
63+
resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
64+
}
6565
}
6666
break;
6767

0 commit comments

Comments
 (0)