wsman-soap-envelope: fix a possible memory leak
In case of duplicate parameters we rewrote stored pointer
and leaking memory.
Release data stored in the pointer before allocating the new one.
@@ -671,13 +671,19 @@ int wsman_parse_credentials(WsXmlDocH doc, WsSubscribeInfo * subsInfo,
node = ws_xml_get_child(node, 0, XML_NS_SE, WSSE_USERNAMETOKEN);
if(node) {
temp = ws_xml_get_child(node, 0, XML_NS_SE, WSSE_USERNAME);
- if(temp)
+ if(temp) {
+ if (subsInfo->username)
+ u_free(subsInfo->username);
subsInfo->username = u_strdup(ws_xml_get_node_text(temp));
+ }
temp = ws_xml_get_child(node, 0, XML_NS_SE, WSSE_PASSWORD);
- if(temp)
+ if(temp) {
+ if (subsInfo->password)
+ u_free(subsInfo->password);
subsInfo->password = u_strdup(ws_xml_get_node_text(temp));
}
}
+ }
debug("subsInfo->username = %s, subsInfo->password = %s", subsInfo->username, \
subsInfo->password);
}
@@ -685,10 +691,13 @@ int wsman_parse_credentials(WsXmlDocH doc, WsSubscribeInfo * subsInfo,
node = ws_xml_get_child(tnode, 0, XML_NS_TRUST, WST_REQUESTEDSECURITYTOKEN);
if(node) {
node = ws_xml_get_child(node, 0, XML_NS_WS_MAN, WSM_CERTIFICATETHUMBPRINT);
- if(node)
+ if(node) {
+ if (subsInfo->certificate_thumbprint)
+ u_free(subsInfo->certificate_thumbprint);
subsInfo->certificate_thumbprint = u_strdup(ws_xml_get_node_text(node));
}
}
+ }
else {
*faultcode = WSMAN_INVALID_OPTIONS;
*detailcode = WST_DETAIL_UNSUPPORTED_TOKENTYPE;
