httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From max...@apache.org
Subject svn commit: r330587 - /httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c
Date Thu, 03 Nov 2005 17:26:10 GMT
Author: maxime
Date: Thu Nov  3 09:26:02 2005
New Revision: 330587

URL: http://svn.apache.org/viewcvs?rev=330587&view=rev
Log:
Avoid memory leaks by using APR memory pools, and some other APR-ification stuff in the MIME
structure parser

Modified:
    httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c

Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c?rev=330587&r1=330586&r2=330587&view=diff
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c Thu Nov  3 09:26:02 2005
@@ -31,7 +31,7 @@
     char *headers_bound = NULL;
 
     /* Locate the end of part headers */
-    headers_bound = strstr(body, "\n\n");
+    headers_bound = ap_strstr(body, "\n\n");
     if (!headers_bound) {
       return NULL;
     }
@@ -40,17 +40,17 @@
        sub-part of the multipart message. The Content-Type header
        should then be the first line of the part. If not, use
        text/plain as default for the sub-part. */
-    tmp = strstr(body, "Content-Type: ");
+    tmp = ap_strstr(body, "Content-Type: ");
     if (!ct && (!tmp || tmp > headers_bound)) {
       ct = "text/plain";
     }
 
-    mail = calloc(1, sizeof(mbox_mime_message_t));
+    mail = apr_pcalloc(p, sizeof(mbox_mime_message_t));
 
     /* If no Content-Type is given, we have to look for it. */
     if (!ct) {
 	tmp += strlen("Content-Type: ");
-	k = strchr(tmp, ';');
+	k = ap_strchr(tmp, ';');
 
 	/* Isolate the Content-Type string (between 'Content-Type: '
 	   and ';' or end of line */
@@ -73,7 +73,7 @@
 	*k = ';';
 
 	/* If available, get MIME part name */
-	tmp = strstr(body, "name=");
+	tmp = ap_strstr(body, "name=");
 	if (tmp && tmp < headers_bound) {
 	    tmp += strlen("name=");
 	    k = tmp;
@@ -103,7 +103,7 @@
     /* Now we have a Content-Type. Look for other useful header information */
 
     /* Check Content-Disposition if the match is within the headers */
-    tmp = strstr(body, "Content-Disposition: ");
+    tmp = ap_strstr(body, "Content-Disposition: ");
     if (tmp && tmp < headers_bound) {
 	tmp += strlen("Content-Disposition: ");
 	k = tmp;
@@ -127,7 +127,7 @@
     /* Check Content-Transfer-Encoding, if needed */
     if (cte == CTE_NONE)
       {
-	  tmp = strstr(body, "Content-Transfer-Encoding: ");
+	  tmp = ap_strstr(body, "Content-Transfer-Encoding: ");
 	  if (tmp && tmp < headers_bound) {
 	      tmp += strlen("Content-Transfer-Encoding: ");
 	      k = tmp;
@@ -158,7 +158,7 @@
         mail->body = body;
     }
     else {
-        mail->body = strstr(body, "\n\n");
+        mail->body = ap_strstr(body, "\n\n");
         if (mail->body != NULL) {
             mail->body += 2;
         }
@@ -172,7 +172,7 @@
 
 	/* If the boundary was not given, we must look for it in the headers */
 	if (!boundary) {
-	    tmp = strstr(body, "boundary=\"");
+	    tmp = ap_strstr(body, "boundary=\"");
 	    if (!tmp) {
 		return NULL;
 	    }
@@ -202,15 +202,14 @@
 	 --boundary-- to mark the end of the MIME part */
 
 	/* The start boundary */
-	bound = strstr(mail->body, mail->boundary);
+	bound = ap_strstr(mail->body, mail->boundary);
 	if (!bound) {
 	    return NULL;
 	}
 
 	/* The end boudary */
-	end_bound = calloc(strlen(mail->boundary)+5, sizeof(char));
-	sprintf(end_bound, "--%s--", mail->boundary);
-	tmp = strstr(mail->body, end_bound);
+	end_bound = apr_psprintf(p, "--%s--", mail->boundary);
+	tmp = ap_strstr(mail->body, end_bound);
 	if (!tmp) {
 	    return NULL;
 	}
@@ -223,7 +222,7 @@
 	while (!end) {
 	    char *inbound;
 
-	    inbound = strstr(search+strlen(mail->boundary), mail->boundary);
+	    inbound = ap_strstr(search+strlen(mail->boundary), mail->boundary);
 	    if (inbound) {
 		char *t = inbound - 2;
 		*t = 0;



Mime
View raw message