From ebfc7378bef3a75469d07c6280d1fa60b9177a9d Mon Sep 17 00:00:00 2001 From: Mohamed Kallel Date: Wed, 7 Aug 2013 16:43:38 +0100 Subject: [PATCH] supporting the tag in the received messages from the acs --- xml.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/xml.c b/xml.c index 2c77c20..7b465df 100644 --- a/xml.c +++ b/xml.c @@ -115,6 +115,10 @@ static int xml_recreate_namespace(mxml_node_t *tree) FREE(ns.xsi); FREE(ns.cwmp); + if (tree->type == MXML_ELEMENT && strstr(tree->value.element.name,"?xml") != NULL) { + tree = mxmlWalkNext(tree, tree, MXML_DESCEND); + } + c = (char *) mxmlElementGetAttrName(tree, soap_env_url); if (c && *(c + 5) == ':') { ns.soap_env = strdup((c + 6)); @@ -297,15 +301,20 @@ int xml_handle_message(struct session *session) /* get method */ - if (asprintf(&c, "%s:%s", ns.soap_env, "Body") == -1) - goto error; + if (asprintf(&c, "%s:%s", ns.soap_env, "Body") == -1) { + CWMP_LOG (INFO,"Internal error"); + session->fault_code = FAULT_CPE_INTERNAL_ERROR; + goto fault; + } b = mxmlFindElement(session->tree_in, session->tree_in, c, NULL, NULL, MXML_DESCEND); FREE(c); - if(!b) - goto error; - + if(!b) { + CWMP_LOG (INFO,"Invalid received message"); + session->fault_code = FAULT_CPE_REQUEST_DENIED; + goto fault; + } session->body_in = b; while (1) { @@ -320,15 +329,23 @@ int xml_handle_message(struct session *session) char *tmp = strchr(c, ':'); size_t ns_len = tmp - c; - if (strlen(ns.cwmp) != ns_len) - goto error; + if (strlen(ns.cwmp) != ns_len) { + CWMP_LOG (INFO,"Invalid received message"); + session->fault_code = FAULT_CPE_REQUEST_DENIED; + goto fault; + } - if (strncmp(ns.cwmp, c, ns_len)) - goto error; + if (strncmp(ns.cwmp, c, ns_len)){ + CWMP_LOG (INFO,"Invalid received message"); + session->fault_code = FAULT_CPE_REQUEST_DENIED; + goto fault; + } c = tmp + 1; } else { - goto error; + CWMP_LOG (INFO,"Invalid received message"); + session->fault_code = FAULT_CPE_REQUEST_DENIED; + goto fault; } CWMP_LOG (INFO,"SOAP RPC message: %s", c); rpc_cpe = NULL; @@ -343,11 +360,13 @@ int xml_handle_message(struct session *session) if (!rpc_cpe) { CWMP_LOG (INFO,"%s RPC is not supported",c); session->fault_code = FAULT_CPE_METHOD_NOT_SUPPORTED; - rpc_cpe = cwmp_add_session_rpc_cpe(session, RPC_CPE_FAULT); - if (rpc_cpe == NULL) goto error; + goto fault; } return 0; - +fault: + rpc_cpe = cwmp_add_session_rpc_cpe(session, RPC_CPE_FAULT); + if (rpc_cpe == NULL) goto error; + return 0; error: return -1; }