You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/10/04 20:26:17 UTC

svn commit: r452964 - /webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c

Author: samisa
Date: Wed Oct  4 11:26:16 2006
New Revision: 452964

URL: http://svn.apache.org/viewvc?view=rev&rev=452964
Log:
Fixed the infinite loop problem

Modified:
    webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c

Modified: webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c?view=diff&rev=452964&r1=452963&r2=452964
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c Wed Oct  4 11:26:16 2006
@@ -34,6 +34,7 @@
 
 #define AXIOM_MIME_PARSER_CONTENT_ID "content-id"
 
+#define AXIOM_MIME_PARSER_END_OF_MIME_MAX_COUNT 100
 /***************************** Function headers *******************************/
 
 axis2_status_t AXIS2_CALL
@@ -266,15 +267,18 @@
         mime_parser_impl->soap_body_str = soap_body_str;
     }
 
-    while (!end_of_mime && count < 10)
+    while (!end_of_mime && count < AXIOM_MIME_PARSER_END_OF_MIME_MAX_COUNT)
     {
         axis2_char_t *temp_body_mime = NULL;
         int temp_body_mime_len = 0;
         pos = NULL;
         len = 0;
-        /* start hack */
-        count ++;
-        /* end hack */
+        
+        /* keep trac of counter to ensure that we do not go in an infinite loop
+           It is possible that we could fall into an infinite loop if there 
+           are problems in sender's message format
+           */
+        count++;
 
         do
         {
@@ -300,6 +304,7 @@
                 len = callback(buffer, size, (void*)callback_ctx);
                 if (len > 0)
                 {
+                    count = 0;
                     temp_body_mime = body_mime;
                     body_mime = AXIS2_MALLOC(env->allocator,
                             sizeof(char) * (body_mime_len + len + 1));
@@ -365,6 +370,7 @@
                 len = callback(buffer, size, (void*)callback_ctx);
                 if (len > 0)
                 {
+                    count = 0;
                     axis2_char_t *temp_mime_binary = mime_binary;
                     mime_binary = AXIS2_MALLOC(env->allocator,
                             sizeof(char) * (mime_binary_len + len + 1));



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org