From 6976490365f8a73ca3849c31185ddce410dce92a Mon Sep 17 00:00:00 2001 From: Fred Rossi Date: Wed, 25 Oct 2023 12:22:56 -0400 Subject: [PATCH] Fix copy TLV value in proxy line and generate header action --- src/connection.c | 4 ++-- src/http_act.c | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/connection.c b/src/connection.c index 2a8199d43f84a..8b69590d7240a 100644 --- a/src/connection.c +++ b/src/connection.c @@ -2054,7 +2054,7 @@ static int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct list_for_each_entry(node, &srv->tlv_list, list) { /* append TLVs from config */ - ret += make_tlv(&buf[ret], (buf_len - ret), node->type, node->len, node); + ret += make_tlv(&buf[ret], (buf_len - ret), node->type, node->len, node->value); } } @@ -2064,7 +2064,7 @@ static int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct list_for_each_entry(node, &remote->tlv_list, list) { /* append remote TLVs */ - ret += make_tlv(&buf[ret], (buf_len - ret), node->type, node->len, node); + ret += make_tlv(&buf[ret], (buf_len - ret), node->type, node->len, node->value); } } diff --git a/src/http_act.c b/src/http_act.c index 3d8f0b1df7fa5..59b36d37239da 100644 --- a/src/http_act.c +++ b/src/http_act.c @@ -1570,10 +1570,12 @@ static int generate_ppv2_tlv_header(struct list *tlv_lists, char *buf, int max_l if (max_len <= (len+tlv_val_len+CODE_LEN)) { break; } - len += snprintf(&buf[len], max_len-len, "0x%02x=", node->type); - len += a2base64((char*)node->value, tlv_val_len, &buf[len], max_len-len); - buf[len++] = ';'; + strncpy(&buf[len], (char*)node->value, tlv_val_len); + len += tlv_val_len; + if (node->list.n != tlv_lists) { + buf[len++] = ';'; + } } return len; @@ -1596,7 +1598,7 @@ static enum act_return http_action_set_ppv2_tlv_header(struct act_rule *rule, st val[0] = '\0'; // req only - if (srv == NULL || rule->from == ACT_F_HTTP_RES) { + if (rule->from == ACT_F_HTTP_RES) { return ret; } @@ -1610,10 +1612,10 @@ static enum act_return http_action_set_ppv2_tlv_header(struct act_rule *rule, st if (len < 1) { return ret; - } + } else if (max_len < len) { val[max_len-1] = '\0'; - } + } else { val[len] = '\0'; } @@ -1710,7 +1712,7 @@ static int generate_ppv2_header(char *buf, int buf_len, const struct sockaddr_st return 0; } - ret = snprintf(buf, buf_len, "address-type=%s;source-address=%s:%u;destination-address=%s:%u;", + ret = snprintf(buf, buf_len, "address-type=%s;source-address=%s:%u;destination-address=%s:%u;", protocol, src_str, ntohs(src_port), dst_str, ntohs(dst_port)); if (ret >= buf_len) @@ -1758,10 +1760,10 @@ static enum act_return http_action_set_ppv2_header(struct act_rule *rule, struct if (len < 1) { return ret; - } + } else if (max_len < len) { val[max_len-1] = '\0'; - } + } else { val[len] = '\0'; }