You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by bi...@apache.org on 2018/08/18 01:35:43 UTC
svn commit: r1838303 - in /axis/axis2/c/core/trunk/axiom:
src/soap/soap12_builder_helper.c test/resources/xml/soap/test.xml
Author: billblough
Date: Sat Aug 18 01:35:43 2018
New Revision: 1838303
URL: http://svn.apache.org/viewvc?rev=1838303&view=rev
Log:
Improve handling of deeply-nested fault subcodes
soap12_builder_helper did not properly handle fault subcodes nested more
than 2 or 3 deep. This caused parsing issues and memory leaks. The new
implementation should handle an arbitrary number of nested subcodes.
Modified:
axis/axis2/c/core/trunk/axiom/src/soap/soap12_builder_helper.c
axis/axis2/c/core/trunk/axiom/test/resources/xml/soap/test.xml
Modified: axis/axis2/c/core/trunk/axiom/src/soap/soap12_builder_helper.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/soap/soap12_builder_helper.c?rev=1838303&r1=1838302&r2=1838303&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/soap/soap12_builder_helper.c (original)
+++ axis/axis2/c/core/trunk/axiom/src/soap/soap12_builder_helper.c Sat Aug 18 01:35:43 2018
@@ -603,6 +603,24 @@ axiom_soap12_builder_helper_handle_event
"fault subcode null when it should not be null");
return AXIS2_FAILURE;
}
+
+ /* Since subcodes can be nested arbitrarily deep, we can't
+ * just take the first subcode - we need to descend until
+ * we find the correct parent
+ */
+ while (sub_code &&
+ axiom_soap_fault_sub_code_get_base_node(sub_code, env) != parent_node)
+ {
+
+ sub_code = axiom_soap_fault_sub_code_get_sub_code(sub_code, env);
+ }
+ if(!sub_code)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "found null when searching for parent subcode");
+ return AXIS2_FAILURE;
+ }
+
value = axiom_soap_fault_value_create(env);
if(!value)
{
@@ -643,6 +661,7 @@ axiom_soap12_builder_helper_handle_event
"fault code null when it should not be null");
return AXIS2_FAILURE;
}
+
parent_subcode = axiom_soap_fault_code_get_sub_code(fault_code, env);
if(!parent_subcode)
{
@@ -651,6 +670,22 @@ axiom_soap12_builder_helper_handle_event
return AXIS2_FAILURE;
}
+ /* Since subcodes can be nested arbitrarily deep, we can't
+ * just take the first subcode - we need to descend until
+ * we find the correct parent
+ */
+ while (parent_subcode &&
+ axiom_soap_fault_sub_code_get_base_node(parent_subcode, env) != parent_node) {
+
+ parent_subcode = axiom_soap_fault_sub_code_get_sub_code(parent_subcode, env);
+ }
+ if(!parent_subcode)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "found null when searching for parent subcode");
+ return AXIS2_FAILURE;
+ }
+
axiom_soap_fault_sub_code_set_sub_code(parent_subcode, env, subcode);
builder_helper->subcode_value_present = AXIS2_FALSE;
Modified: axis/axis2/c/core/trunk/axiom/test/resources/xml/soap/test.xml
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/test/resources/xml/soap/test.xml?rev=1838303&r1=1838302&r2=1838303&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/test/resources/xml/soap/test.xml (original)
+++ axis/axis2/c/core/trunk/axiom/test/resources/xml/soap/test.xml Sat Aug 18 01:35:43 2018
@@ -47,6 +47,12 @@
<env:Value>m:MessageTimeout In Second Subcode</env:Value>
<env:Subcode>
<env:Value>m:MessageTimeout In Third Subcode</env:Value>
+ <env:Subcode>
+ <env:Value>m:MessageTimeout In Fourth Subcode</env:Value>
+ <env:Subcode>
+ <env:Value>m:MessageTimeout In Fifth Subcode</env:Value>
+ </env:Subcode>
+ </env:Subcode>
</env:Subcode>
</env:Subcode>
</env:Subcode>