File SIP_body_len_underflow.patch of Package libosip2.4662

--- a/libosip2/src/osipparser2/osip_message_parse.c
+++ b/libosip2/src/osipparser2/osip_message_parse.c
@@ -822,6 +822,16 @@
 		if ('\n' == start_of_body[0] || '\r' == start_of_body[0])
 			start_of_body++;
 
+                /* Bail out if message body is empty or contains a single CR/LF */
+                /* If '\n++--\r\n++--', then end_of_body = start_of_body - 1    */
+                /* If '\n++--\r\r\n++--', then end_of_body = start_of_body      */
+                /* If '\n++--\r\n\n++--', then end_of_body = start_of_body      */
+                if (end_of_body <= start_of_body) {
+                        osip_free (sep_boundary);
+                        OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not parse message body.\n"));
+                        return OSIP_SYNTAXERROR;
+                }
+
 		body_len = end_of_body - start_of_body;
 
 		/* Skip CR before end boundary. */
openSUSE Build Service is sponsored by