Skip to content
Permalink
Browse files
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.
  • Loading branch information
bblough committed Aug 18, 2018
1 parent b94fb9e commit 2fb6490c382ae15143784b1d38b76542c4fd8b90
Showing 2 changed files with 41 additions and 0 deletions.
@@ -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;
@@ -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>

0 comments on commit 2fb6490

Please sign in to comment.