httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1198959 - /httpd/httpd/trunk/modules/metadata/mod_usertrack.c
Date Mon, 07 Nov 2011 21:47:40 GMT
Author: sf
Date: Mon Nov  7 21:47:39 2011
New Revision: 1198959

URL: http://svn.apache.org/viewvc?rev=1198959&view=rev
Log:
More checks of ap_pregsub return values

Modified:
    httpd/httpd/trunk/modules/metadata/mod_usertrack.c

Modified: httpd/httpd/trunk/modules/metadata/mod_usertrack.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/metadata/mod_usertrack.c?rev=1198959&r1=1198958&r2=1198959&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/metadata/mod_usertrack.c (original)
+++ httpd/httpd/trunk/modules/metadata/mod_usertrack.c Mon Nov  7 21:47:39 2011
@@ -62,6 +62,7 @@
 #include "http_config.h"
 #include "http_core.h"
 #include "http_request.h"
+#include "http_log.h"
 
 
 module AP_MODULE_DECLARE_DATA usertrack_module;
@@ -219,6 +220,7 @@ static int spot_cookie(request_rec *r)
     if ((cookie_header = apr_table_get(r->headers_in, "Cookie"))) {
         if (!ap_regexec(dcfg->regexp, cookie_header, NUM_SUBS, regm, 0)) {
             char *cookieval = NULL;
+            int err = 0;
             /* Our regexp,
              * ^cookie_name=([^;]+)|;[ \t]+cookie_name=([^;]+)
              * only allows for $1 or $2 to be available. ($0 is always
@@ -228,10 +230,19 @@ static int spot_cookie(request_rec *r)
             if (regm[1].rm_so != -1) {
                 cookieval = ap_pregsub(r->pool, "$1", cookie_header,
                                        NUM_SUBS, regm);
+                if (cookieval == NULL)
+                    err = 1;
             }
             if (regm[2].rm_so != -1) {
                 cookieval = ap_pregsub(r->pool, "$2", cookie_header,
                                        NUM_SUBS, regm);
+                if (cookieval == NULL)
+                    err = 1;
+            }
+            if (err) {
+                ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r,
+                              "Failed to extract cookie value (out of mem?)");
+                return HTTP_INTERNAL_SERVER_ERROR;
             }
             /* Set the cookie in a note, for logging */
             apr_table_setn(r->notes, "cookie", cookieval);



Mime
View raw message