TSG-14802 修复代理日志中common_service_category字段填写错误

This commit is contained in:
fengweihao
2023-04-18 17:52:24 +08:00
parent 915dd00731
commit 1430681184

View File

@@ -86,7 +86,7 @@ error_out:
return NULL; return NULL;
} }
static unsigned int proxy_log_get_fqdn_cat(struct tfe_cmsg *cmsg, unsigned int *category_id_val) static unsigned int proxy_log_get_fqdn_cat(struct tfe_cmsg *cmsg, unsigned int *category_id_val, size_t sz_out_value_buf)
{ {
int ret=0; int ret=0;
unsigned category_id_num=0; unsigned category_id_num=0;
@@ -97,7 +97,7 @@ static unsigned int proxy_log_get_fqdn_cat(struct tfe_cmsg *cmsg, unsigned int *
{ {
return -1; return -1;
} }
ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_FQDN_CAT_ID_VAL, (unsigned char *)category_id_val, sizeof(category_id_val), &opt_out_size); ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_FQDN_CAT_ID_VAL, (unsigned char *)category_id_val, sz_out_value_buf, &opt_out_size);
if (ret != 0) if (ret != 0)
{ {
return -1; return -1;
@@ -152,7 +152,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg)
cJSON_AddStringToObject(common_obj, "http_version", app_proto[http->major_version]); cJSON_AddStringToObject(common_obj, "http_version", app_proto[http->major_version]);
cJSON_AddStringToObject(common_obj, "common_schema_type", "HTTP"); cJSON_AddStringToObject(common_obj, "common_schema_type", "HTTP");
unsigned int common_direction=0, category_id_val[8]={0}; unsigned int common_direction=0, category_id_val[64]={0};
char opt_val[24]={0}; uint16_t opt_out_size; char opt_val[24]={0}; uint16_t opt_out_size;
struct tfe_cmsg * cmsg = tfe_stream_get0_cmsg(log_msg->stream); struct tfe_cmsg * cmsg = tfe_stream_get0_cmsg(log_msg->stream);
if (cmsg!=NULL) if (cmsg!=NULL)
@@ -167,7 +167,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg)
{ {
cJSON_AddNumberToObject(common_obj, "common_direction", common_direction); //0域内->域外1域外->域内描述的是CLIENT_IP信息 cJSON_AddNumberToObject(common_obj, "common_direction", common_direction); //0域内->域外1域外->域内描述的是CLIENT_IP信息
} }
ret = proxy_log_get_fqdn_cat(cmsg, category_id_val); ret = proxy_log_get_fqdn_cat(cmsg, category_id_val, sizeof(category_id_val));
if (ret>0) if (ret>0)
{ {
cJSON_AddItemToObject(common_obj, "common_service_category", cJSON_CreateIntArray((const int*)category_id_val, ret)); cJSON_AddItemToObject(common_obj, "common_service_category", cJSON_CreateIntArray((const int*)category_id_val, ret));