You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ma...@apache.org on 2005/11/03 18:56:49 UTC
svn commit: r330591 - in /httpd/mod_mbox/trunk/module-2.0: mod_mbox_cte.c
mod_mbox_mime.c
Author: maxime
Date: Thu Nov 3 09:54:05 2005
New Revision: 330591
URL: http://svn.apache.org/viewcvs?rev=330591&view=rev
Log:
Avoid crash in decoding routine when message body is NULL. Add a failsafe in the decoding function, and a small note to programmers
Modified:
httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c
httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c
Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c?rev=330591&r1=330590&r2=330591&view=diff
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_cte.c Thu Nov 3 09:54:05 2005
@@ -15,6 +15,8 @@
*/
/* Decoding common Content-Encodings of E-Mail functions.
+ *
+ * These decoding functions do not copy data.
*/
#include "mod_mbox.h"
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=330591&r1=330590&r2=330591&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:54:05 2005
@@ -277,7 +277,15 @@
/* Decode a MIME part body, according to its CTE. */
char *mbox_mime_decode_body(apr_pool_t *p, mbox_cte_e cte, char *body, apr_size_t len)
{
- char *new_body = apr_pstrndup(p, body, len);
+ char *new_body;
+
+ /* Failsafe : in case of body == NULL, apr_pstrndup will not
+ allocate anything, not even one byte for the '\0' */
+ if (!body) {
+ return NULL;
+ }
+
+ new_body = apr_pstrndup(p, body, len);
if (cte == CTE_BASE64) {
len = mbox_cte_decode_b64(new_body);
@@ -298,7 +306,9 @@
{
int i;
- if (!m) {
+ /* If the message structure or the message body is empty, just
+ return NULL */
+ if (!m || !m->body) {
return NULL;
}