Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 26DCD914E for ; Fri, 13 Apr 2012 17:56:19 +0000 (UTC) Received: (qmail 62597 invoked by uid 500); 13 Apr 2012 17:56:19 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 62543 invoked by uid 500); 13 Apr 2012 17:56:18 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 62536 invoked by uid 99); 13 Apr 2012 17:56:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Apr 2012 17:56:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Apr 2012 17:56:11 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EA4C12388C16; Fri, 13 Apr 2012 17:55:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1325874 - /httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c Date: Fri, 13 Apr 2012 17:55:50 -0000 To: cvs@httpd.apache.org From: sf@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120413175550.EA4C12388C16@eris.apache.org> Author: sf Date: Fri Apr 13 17:55:50 2012 New Revision: 1325874 URL: http://svn.apache.org/viewvc?rev=1325874&view=rev Log: mbox_cte_decode_header(): allow NULL strings and handle strings efficiently where nothing needs to be done Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c?rev=1325874&r1=1325873&r2=1325874&view=diff ============================================================================== --- httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c (original) +++ httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c Fri Apr 13 17:55:50 2012 @@ -376,20 +376,23 @@ static char *mbox_cte_decode_rfc2047(apr /* MIME header decoding (see RFC 2047). */ char *mbox_cte_decode_header(apr_pool_t *p, char *src) { - char *start, *end, *cont; + char *start, *end = NULL, *cont; struct ap_varbuf vb; int seen_encoded_word = 0; - ap_varbuf_init(p, &vb, 100); + if (src == NULL || *src == '\0') + return ""; + ap_varbuf_init(p, &vb, 0); vb.strlen = 0; do { start = strstr(src, "=?"); - if (!start) - return apr_pstrcat(p, vb.buf, src, NULL); - - end = strstr(start, "?="); - if (!end) + if (start) + end = strstr(start, "?="); + if (!start || !end) { + if (vb.strlen == 0) + return src; return apr_pstrcat(p, vb.buf, src, NULL); + } if (start != src) { if (seen_encoded_word) { @@ -399,7 +402,7 @@ char *mbox_cte_decode_header(apr_pool_t p++; if (p == start) src = start; - /* XXX: this is wrong if the next encoded word fails to decode */ + /* XXX: this is wrong if the next encoded word fails to decode */ } if (start != src) { ap_varbuf_strmemcat(&vb, src, start - src);