Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 96891 invoked from network); 6 May 2007 14:35:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 May 2007 14:35:26 -0000 Received: (qmail 23324 invoked by uid 500); 6 May 2007 14:35:33 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 23183 invoked by uid 500); 6 May 2007 14:35:32 -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 23172 invoked by uid 99); 6 May 2007 14:35:32 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 May 2007 07:35:32 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 May 2007 07:35:25 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 38B021A9838; Sun, 6 May 2007 07:35:05 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r535617 - /httpd/httpd/trunk/modules/cache/cache_util.c Date: Sun, 06 May 2007 14:35:04 -0000 To: cvs@httpd.apache.org From: rpluem@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070506143505.38B021A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rpluem Date: Sun May 6 07:35:02 2007 New Revision: 535617 URL: http://svn.apache.org/viewvc?view=rev&rev=535617 Log: * Prevent a segmentation fault if one of the Cache-Control headers s-maxage, max-age, min-fresh, max-stale has no value assigned. In this case ignore s-maxage, max-age, min-fresh. For max-stale it is valid to set no value. In this case set max-stale to 1 year to signal that the client is accepting a stale response of any age. Submitted by: Niklas Edmundsson Reviewed by: rpluem Modified: httpd/httpd/trunk/modules/cache/cache_util.c Modified: httpd/httpd/trunk/modules/cache/cache_util.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.c?view=diff&rev=535617&r1=535616&r2=535617 ============================================================================== --- httpd/httpd/trunk/modules/cache/cache_util.c (original) +++ httpd/httpd/trunk/modules/cache/cache_util.c Sun May 6 07:35:02 2007 @@ -243,7 +243,8 @@ age = ap_cache_current_age(info, age_c, r->request_time); /* extract s-maxage */ - if (cc_cresp && ap_cache_liststr(r->pool, cc_cresp, "s-maxage", &val)) { + if (cc_cresp && ap_cache_liststr(r->pool, cc_cresp, "s-maxage", &val) + && val != NULL) { smaxage = apr_atoi64(val); } else { @@ -252,7 +253,8 @@ /* extract max-age from request */ if (!conf->ignorecachecontrol - && cc_req && ap_cache_liststr(r->pool, cc_req, "max-age", &val)) { + && cc_req && ap_cache_liststr(r->pool, cc_req, "max-age", &val) + && val != NULL) { maxage_req = apr_atoi64(val); } else { @@ -260,7 +262,8 @@ } /* extract max-age from response */ - if (cc_cresp && ap_cache_liststr(r->pool, cc_cresp, "max-age", &val)) { + if (cc_cresp && ap_cache_liststr(r->pool, cc_cresp, "max-age", &val) + && val != NULL) { maxage_cresp = apr_atoi64(val); } else { @@ -282,7 +285,20 @@ /* extract max-stale */ if (cc_req && ap_cache_liststr(r->pool, cc_req, "max-stale", &val)) { - maxstale = apr_atoi64(val); + if(val != NULL) { + maxstale = apr_atoi64(val); + } + else { + /* + * If no value is assigned to max-stale, then the client is willing + * to accept a stale response of any age (RFC2616 14.9.3). We will + * set it to one year in this case as this situation is somewhat + * similar to a "never expires" Expires header (RFC2616 14.21) + * which is set to a date one year from the time the response is + * sent in this case. + */ + maxstale = APR_INT64_C(86400*365); + } } else { maxstale = 0; @@ -290,7 +306,8 @@ /* extract min-fresh */ if (!conf->ignorecachecontrol - && cc_req && ap_cache_liststr(r->pool, cc_req, "min-fresh", &val)) { + && cc_req && ap_cache_liststr(r->pool, cc_req, "min-fresh", &val) + && val != NULL) { minfresh = apr_atoi64(val); } else { @@ -418,6 +435,9 @@ *val = apr_pstrmemdup(p, val_start, next - val_start); } + } + else { + *val = NULL; } } return 1;