mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Fix random crash on big payloads
This commit is contained in:
parent
79ac3e0d5a
commit
8522bf195f
3 changed files with 33 additions and 10 deletions
|
|
@ -35,7 +35,7 @@ run_unit_test:
|
||||||
|
|
||||||
run_api_test:
|
run_api_test:
|
||||||
stage: functional_test
|
stage: functional_test
|
||||||
image: "${COMMON_IMAGE}"
|
image: "dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:0.31"
|
||||||
services:
|
services:
|
||||||
- name: dev.iopsys.eu:5050/lcm/swmodd/acs:latest
|
- name: dev.iopsys.eu:5050/lcm/swmodd/acs:latest
|
||||||
alias: acs
|
alias: acs
|
||||||
|
|
@ -56,7 +56,7 @@ run_api_test:
|
||||||
|
|
||||||
run_functional_test:
|
run_functional_test:
|
||||||
stage: functional_test
|
stage: functional_test
|
||||||
image: "${COMMON_IMAGE}"
|
image: "dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:0.31"
|
||||||
services:
|
services:
|
||||||
- name: dev.iopsys.eu:5050/lcm/swmodd/acs:latest
|
- name: dev.iopsys.eu:5050/lcm/swmodd/acs:latest
|
||||||
alias: acs
|
alias: acs
|
||||||
|
|
|
||||||
|
|
@ -846,7 +846,7 @@ void cwmp_lwnotification()
|
||||||
udplw_server_param(&servaddr);
|
udplw_server_param(&servaddr);
|
||||||
xml_prepare_lwnotification_message(&msg_out);
|
xml_prepare_lwnotification_message(&msg_out);
|
||||||
if (msg_out == NULL) {
|
if (msg_out == NULL) {
|
||||||
CWMP_LOG(ERROR, "notifications %s: msg_out is null", __FUNCTION__);
|
CWMP_LOG(ERROR, "%s: msg_out is null", __FUNCTION__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
message_compute_signature(msg_out, signature, sizeof(signature));
|
message_compute_signature(msg_out, signature, sizeof(signature));
|
||||||
|
|
|
||||||
37
src/xml.c
37
src/xml.c
|
|
@ -226,6 +226,32 @@ char* xml_tags_names[] = {
|
||||||
"IsDownload"
|
"IsDownload"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *convert_xml_node_to_string(mxml_node_t *node, mxml_save_cb_t cb)
|
||||||
|
{
|
||||||
|
char *str = NULL;
|
||||||
|
int bytes = 0;
|
||||||
|
|
||||||
|
// Determine the size of the XML node
|
||||||
|
bytes = mxmlSaveString(node, NULL, 0, cb);
|
||||||
|
if (bytes <= 0) {
|
||||||
|
CWMP_LOG(ERROR, "XML node received is empty");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate a buffer of the required size
|
||||||
|
str = (char *)malloc(bytes + 1);
|
||||||
|
if (str == NULL) {
|
||||||
|
CWMP_LOG(ERROR, "Failed to allocate %d bytes for the XML node string due to insufficient space", bytes + 1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the XML node into the allocated buffer
|
||||||
|
mxmlSaveString(node, str, bytes + 1, cb);
|
||||||
|
|
||||||
|
// Return the allocated string
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
int get_xml_tags_array_total_size(int tag_ref)
|
int get_xml_tags_array_total_size(int tag_ref)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -1398,10 +1424,10 @@ int xml_send_message(struct rpc *rpc)
|
||||||
if (cwmp_main->session->tree_out) {
|
if (cwmp_main->session->tree_out) {
|
||||||
unsigned char *zmsg_out;
|
unsigned char *zmsg_out;
|
||||||
|
|
||||||
msg_out = mxmlSaveAllocString(cwmp_main->session->tree_out, whitespace_cb);
|
msg_out = convert_xml_node_to_string(cwmp_main->session->tree_out, whitespace_cb);
|
||||||
FREE(g_tab_space);
|
FREE(g_tab_space);
|
||||||
if (msg_out == NULL) {
|
if (msg_out == NULL) {
|
||||||
CWMP_LOG(ERROR, "Received tree_out is empty");
|
CWMP_LOG(ERROR, "%s: msg_out is null", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1621,15 +1647,12 @@ int xml_prepare_lwnotification_message(char **msg_out)
|
||||||
|
|
||||||
load_notification_xml_schema(&lw_tree);
|
load_notification_xml_schema(&lw_tree);
|
||||||
if (!lw_tree)
|
if (!lw_tree)
|
||||||
goto error;
|
return -1;;
|
||||||
|
|
||||||
*msg_out = mxmlSaveAllocString(lw_tree, MXML_NO_CALLBACK);
|
*msg_out = convert_xml_node_to_string(lw_tree, MXML_NO_CALLBACK);
|
||||||
|
|
||||||
mxmlDelete(lw_tree);
|
mxmlDelete(lw_tree);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_notification_xml_schema(mxml_node_t **tree)
|
void load_notification_xml_schema(mxml_node_t **tree)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue