Merge pull request #2832 from fengzeroz/main

fix memory issue
This commit is contained in:
fengzeroz
2026-06-26 11:29:11 +08:00
committed by GitHub
4 changed files with 37 additions and 22 deletions
+2 -1
View File
@@ -204,7 +204,8 @@ void recv_data_callback(void *arg)
body_str = nng_msg_body(msg);
body_len = nng_msg_len(msg);
if (*(uint8_t *) body_str == 0x0A && *(uint8_t *) (body_str + 1) == 0xCE) {
if (body_len >= 26 && *(uint8_t *) body_str == 0x0A &&
*(uint8_t *) (body_str + 1) == 0xCE) {
// trace
trace_id = (uint8_t *) (body_str + 2);
span_id = (uint8_t *) (body_str + 18);
+4 -2
View File
@@ -586,8 +586,10 @@ int modbus_value_handle_test(neu_plugin_t *plugin, void *req,
break;
case MODBUS_AREA_COIL:
case MODBUS_AREA_INPUT: {
neu_value8_u u8 = { .value = bytes[0] };
jvalue.val_bit = neu_value8_get_bit(u8, 0);
if (n_byte >= 1) {
neu_value8_u u8 = { .value = bytes[0] };
jvalue.val_bit = neu_value8_get_bit(u8, 0);
}
} break;
}
+10 -7
View File
@@ -1033,29 +1033,32 @@ void neu_otel_split_traceparent(const char *in, char *trace_id, char *span_id,
char * copy = strdup(in);
char t_flags[32] = { 0 };
const size_t trace_id_cap = 64;
const size_t span_id_cap = 32;
token = strtok_r(copy, delimiter, &saveptr);
token = strtok_r(NULL, delimiter, &saveptr);
if (token != NULL) {
strcpy(trace_id, token);
snprintf(trace_id, trace_id_cap, "%s", token);
} else {
strcpy(trace_id, "");
trace_id[0] = '\0';
}
token = strtok_r(NULL, delimiter, &saveptr);
if (token != NULL) {
strcpy(span_id, token);
snprintf(span_id, span_id_cap, "%s", token);
} else {
strcpy(span_id, "");
span_id[0] = '\0';
}
token = strtok_r(NULL, delimiter, &saveptr);
if (token != NULL) {
strcpy(t_flags, token);
snprintf(t_flags, sizeof(t_flags), "%s", token);
sscanf(t_flags, "%x", flags);
} else {
strcpy(t_flags, "");
*flags = 0;
t_flags[0] = '\0';
*flags = 0;
}
free(copy);
+21 -12
View File
@@ -540,7 +540,7 @@ static int parse_ied(xmlNode *xml_ied, cid_ied_t *ied)
memset(ap, 0, sizeof(cid_access_point_t));
if (name != NULL) {
strcpy(ap->name, name);
snprintf(ap->name, sizeof(ap->name), "%s", name);
xmlFree(name);
}
@@ -581,7 +581,7 @@ static int parse_ldevice(xmlNode *xml_server, cid_access_point_t *ap)
memset(ldev, 0, sizeof(cid_ldevice_t));
char *inst = (char *) xmlGetProp(ldevice, (const xmlChar *) "inst");
if (inst != NULL) {
strcpy(ldev->inst, inst);
snprintf(ldev->inst, sizeof(ldev->inst), "%s", inst);
xmlFree(inst);
}
int ret = parse_lnode(ldevice, ldev);
@@ -903,8 +903,9 @@ static int parse_template(xmlNode *xml_template, cid_template_t *template)
&template->lnotypes[template->n_lnotypes - 1];
memset(tm_lno, 0, sizeof(cid_tm_lno_type_t));
strcpy(tm_lno->id, id);
strcpy(tm_lno->ln_class, ln_class);
snprintf(tm_lno->id, sizeof(tm_lno->id), "%s", id);
snprintf(tm_lno->ln_class, sizeof(tm_lno->ln_class), "%s",
ln_class);
xmlNode *xdo = child->children;
while (xdo != NULL) {
@@ -926,8 +927,9 @@ static int parse_template(xmlNode *xml_template, cid_template_t *template)
&tm_lno->dos[tm_lno->n_dos - 1];
memset(tm_do, 0, sizeof(cid_tm_lno_do_t));
strcpy(tm_do->name, name);
strcpy(tm_do->ref_type, ref_type);
snprintf(tm_do->name, sizeof(tm_do->name), "%s", name);
snprintf(tm_do->ref_type, sizeof(tm_do->ref_type), "%s",
ref_type);
}
if (name != NULL) {
@@ -982,8 +984,10 @@ static int parse_template(xmlNode *xml_template, cid_template_t *template)
&tm_do->sdos[tm_do->n_sdos - 1];
memset(tm_sdo, 0, sizeof(cid_tm_sdo_t));
strcpy(tm_sdo->name, sdo_name);
strcpy(tm_sdo->ref_type, sdo_ref_type);
snprintf(tm_sdo->name, sizeof(tm_sdo->name), "%s",
sdo_name);
snprintf(tm_sdo->ref_type, sizeof(tm_sdo->ref_type),
"%s", sdo_ref_type);
}
if (sdo_name != NULL) {
@@ -1015,9 +1019,12 @@ static int parse_template(xmlNode *xml_template, cid_template_t *template)
&tm_do->das[tm_do->n_das - 1];
memset(tm_da, 0, sizeof(cid_tm_do_da_t));
strcpy(tm_da->name, name);
snprintf(tm_da->name, sizeof(tm_da->name), "%s",
name);
if (ref_type != NULL) {
strcpy(tm_da->ref_type, ref_type);
snprintf(tm_da->ref_type,
sizeof(tm_da->ref_type), "%s",
ref_type);
}
tm_da->btype = T_UNKNOWN;
tm_da->btype =
@@ -1101,9 +1108,11 @@ static int parse_template(xmlNode *xml_template, cid_template_t *template)
cid_tm_bda_type_t *tm_bda =
&tm_dat->bdas[tm_dat->n_bdas - 1];
memset(tm_bda, 0, sizeof(cid_tm_bda_type_t));
strcpy(tm_bda->name, name);
snprintf(tm_bda->name, sizeof(tm_bda->name), "%s",
name);
if (ref_type != NULL) {
strcpy(tm_bda->ref_type, ref_type);
snprintf(tm_bda->ref_type, sizeof(tm_bda->ref_type),
"%s", ref_type);
}
tm_bda->btype = T_UNKNOWN;
tm_bda->btype = decode_basictype((const char *) btype);