You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2015/03/12 17:47:03 UTC

svn commit: r1666255 - in /tcl/rivet/trunk: ChangeLog doc/xml/internals.xml src/mod_rivet/mod_rivet.c

Author: mxmanghi
Date: Thu Mar 12 16:47:03 2015
New Revision: 1666255

URL: http://svn.apache.org/r1666255
Log:
2015-03-11 Massimo Manghi <mx...@apache.org>
    * doc/xml/internals.xml: Improved paragraph on how to extend mod_rivet
    * src/apache-2/mod_rivet.c: Improper handling of 'HTTP_NOT_FOUND' and
    HTTP_INTERNAL_SERVER_ERROR caused an access to non existing memory (Bug #57686)


Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/doc/xml/internals.xml
    tcl/rivet/trunk/src/mod_rivet/mod_rivet.c

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1666255&r1=1666254&r2=1666255&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Thu Mar 12 16:47:03 2015
@@ -1,3 +1,8 @@
+2015-03-11 Massimo Manghi <mx...@apache.org>
+    * doc/xml/internals.xml: Improved paragraph on how to extend mod_rivet
+    * src/apache-2/mod_rivet.c: Improper handling of 'HTTP_NOT_FOUND' and
+    HTTP_INTERNAL_SERVER_ERROR caused an access to non existing memory (Bug #57686)
+
 2015-02-20 Massimo Manghi <mx...@apache.org>
     * INSTALL: updating examples and version
     * src/mod_rivet/mod_rivet.c: Restoring usual Rivet/VERSION signature

Modified: tcl/rivet/trunk/doc/xml/internals.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/doc/xml/internals.xml?rev=1666255&r1=1666254&r2=1666255&view=diff
==============================================================================
--- tcl/rivet/trunk/doc/xml/internals.xml (original)
+++ tcl/rivet/trunk/doc/xml/internals.xml Thu Mar 12 16:47:03 2015
@@ -94,20 +94,30 @@
         <title>Extending Rivet by developing C procedures implementing new commands</title>
         <para>
             Rivet endows the Tcl interpreter with new commands
-            to provide an interface from the application layer to the
-            Apache web server internal data. Many of these commands
-            are meaningful only when HTTP request are being processed
-            and a fundamental data structure has been allocated and
-            intialized by the Apache framework: the request_rec object. 
-            In case commands have to be written that have to gain access 
-            to a valid request_rec object pointer they must check if such 
+            serving as interface between the application layer and the
+            Apache web server. Many of these commands
+            are meaningful only when a HTTP request is under way and 
+            therefore a request_rec object allocated by the framework 
+            is existing and was passed to mod_rivet as argument of a callback. 
+            In case commands have to gain access to a valid request_rec
+            object the C procedure must check if such 
             a pointer exists and it's initialized
-            with valid data. 
+            with valid data. For this purpose the procedure handling requests 
+            (Rivet_SendContent) makes a copy of such pointer and keeps it
+            in an internal structure. The copy is set to NULL just before
+            returning to the framework, right after mod_rivet's has
+            carried out its request processing. When the pointer copy is NULL 
+            the module is outside any request processing and this
+            condition invalidates the execution of
+            many of the Rivet commands. In case they are called  
+            (for example in a ChildInitScript, GlobalInitScript, 
+            ServerInitScript or ChildExitScript) they fail with a Tcl error 
+            you can handle with a <command>catch</command> command.
         </para>
         <para>            
             For this purpose in <option>src/rivet.h</option> the macro
-            CHECK_REQUEST_REC was defined accepting to arguments: the pointer
-            to the request_rec object (stored in the 
+            CHECK_REQUEST_REC was defined accepting two arguments: the copy
+            to the request_rec pointer (stored in the 
             <structname>rivet_interp_globals</structname>
             structure) and the command name. If the pointer is NULL
             the macro calls Tcl_NoRequestRec and returns TCL_ERROR

Modified: tcl/rivet/trunk/src/mod_rivet/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet/mod_rivet.c?rev=1666255&r1=1666254&r2=1666255&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/mod_rivet/mod_rivet.c Thu Mar 12 16:47:03 2015
@@ -590,13 +590,13 @@ Rivet_SendContent(rivet_thread_private *
     globals->private = private;
 
     /* The current TclWebRequest record is assigned here to the thread private data
-       for the channel to read it when actual output will flushed */
+       for the channel to read it when the internal buffer will be flushed */
     
     private->req = globals->req;
 
     /* Setting this pointer in globals is crucial: by assigning it
-     * we signal to Rivet commands we are processing an HTTP request.
-     * This pointer gets set to NULL just before we leave this function
+     * we signal we are processing an HTTP request.
+     * This pointer is set to NULL just before we leave this function
      * making possible to invalidate command execution that could depend
      * on a valid request_rec
      */
@@ -686,7 +686,7 @@ Rivet_SendContent(rivet_thread_private *
     if (r->header_only && !private->running_conf->honor_header_only_reqs)
     {
         TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE, globals->req);
-        //TclWeb_PrintHeaders(globals->req);
+        TclWeb_PrintHeaders(globals->req);
         retval = OK;
         goto sendcleanup;
     }
@@ -755,6 +755,12 @@ Rivet_SendContent(rivet_thread_private *
                      Tcl_GetVar(interp, "errorInfo", 0));
     }
 
+    /* We finalize the request processing by printing the headers and flushing
+       the rivet channel internal buffer */
+
+    TclWeb_PrintHeaders(globals->req);
+    Tcl_Flush(*(running_channel));
+
     /* Reset globals */
     Rivet_CleanupRequest(r);
 
@@ -768,11 +774,7 @@ sendcleanup:
     //                          globals->req->charset,NULL),globals->req);
     //}
 
-    TclWeb_PrintHeaders(globals->req);
-    Tcl_Flush(*(running_channel));
-
     globals->req->content_sent = 0;
-
     globals->page_aborting = 0;
     if (globals->abort_code != NULL)
     {



---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org