Limit envelope size to 32767 if wsman:MaxEnvelopeSize not set.

A service should not send a SOAP Envelope with more then 32767 octets unless the client has specified a wsman:MaxEnvelopeSize header

Signed-off-by: prabhakar pujeri <prabhakar_pujeri@dell.com>
Signed-off-by: Klaus Kämpf <kkaempf@suse.de>
diff --git a/include/wsman-xml-api.h b/include/wsman-xml-api.h
index 992c8f4..de2d42f 100644
--- a/include/wsman-xml-api.h
+++ b/include/wsman-xml-api.h
@@ -84,6 +84,7 @@
 
 #define PROCESSED_MSG_ID_MAX_SIZE            200
 #define WSMAN_MINIMAL_ENVELOPE_SIZE_REQUEST  8192
+#define WSMAN_MAX_ENVELOPE_SIZE 32767
 
 
 void ws_xml_free_memory(void *ptr);
diff --git a/src/lib/wsman-dispatcher.c b/src/lib/wsman-dispatcher.c
index dd8c529..1833b0c 100644
--- a/src/lib/wsman-dispatcher.c
+++ b/src/lib/wsman-dispatcher.c
@@ -207,12 +207,22 @@
 	header = wsman_get_soap_header_element( op->in_doc,  NULL, NULL);
 	maxsize = ws_xml_get_child(header, 0, XML_NS_WS_MAN,
 			     WSM_MAX_ENVELOPE_SIZE);
-	mu = ws_xml_find_attr_value(maxsize, XML_NS_SOAP_1_2,
+        /* DSP0226, v1.2
+         * R13.1-3: A service should not send a SOAP Envelope with more than 32,767 octets unless the
+         * client has specified a wsman:MaxEnvelopeSize header that overrides this limit
+         */
+        if (maxsize == NULL) { /* no wsman:MaxEnvelopeSize specified */
+          op->maxsize = WSMAN_MAX_ENVELOPE_SIZE;
+        }
+        else {
+          mu = ws_xml_find_attr_value(maxsize, XML_NS_SOAP_1_2,
 				    SOAP_MUST_UNDERSTAND);
+        }
 	if (mu != NULL && strcmp(mu, "true") == 0) {
 		size = ws_deserialize_uint32(NULL, header,
 					     0, XML_NS_WS_MAN,
 					     WSM_MAX_ENVELOPE_SIZE);
+                /* wsman:MaxEnvelopeSize too small ? */
 		if (size < WSMAN_MINIMAL_ENVELOPE_SIZE_REQUEST) {
 			generate_op_fault(op, WSMAN_ENCODING_LIMIT,
 						WSMAN_DETAIL_MINIMUM_ENVELOPE_LIMIT);