>Number:         2060
>Category:       os-windows
>Synopsis:       Apache is less forgiving implementing 
>HSE_REQ_SEND_RESPONSE_HEADER
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Mon Apr 13 10:20:01 PDT 1998
>Last-Modified:
>Originator:     [EMAIL PROTECTED]
>Organization:
apache
>Release:        1.3b5
>Environment:
NT 4.0 SP3
Microsoft Visual C++ 5.0
>Description:
We have an ISAPI module used to support an application that we sell. This module
does not work correctly with Apache 1.3B5

I tracked down the problem to the implementation of the 
HSE_REQ_SEND_RESPONSE_HEADER
function. In Apache, the extra headers argument MUST be terminated with \r\n .
In IIS, it seems that is not the case.

Note: Apache does seem to be following the documentation on this, but not all
ISAPI extensions will be doing so since IIS does not seem to enforce it. I know 
that we could correct our ISAPI extension, but I also know that management
will be reluctant to do this just to support a "non-standard" web server.
>How-To-Repeat:
1. Create an ISAPI extension module using Visual C++'s "ISAPI Extension" 
wizard. 
2. In the function "CBugisapiExtension::Default" of the main source file, add
this line at the top of the module:
        AddHeader(pCtxt, "content-type: text/plain");
3. Build the dll and move it into your cgi-bin location.
4. Invoke the "dll" e.g. using URL "http://localhost/cgi-bin/mine.dll";

You should see an error with the 1.3b5 implementation of Apache. With the 
patch, or
or if you use IIS, you will see the default implementation of the DLL generated 
by the
wizard.
>Fix:
Here is a patch:
*** temp/apache_1.3b5/src/os/win32/mod_isapi.c Mon Feb  2 23:29:54 1998
--- source/apache_1.3b5/src/os/win32/mod_isapi.c Mon Apr 13 09:18:30 1998
***************
*** 418,437 ****
            int p;
  
            if (!lf) { /* Huh? Invalid data, I think */
                aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                            "ISA sent invalid headers: %s", r->filename);
                SetLastError(ERROR);    /* XXX: Find right error */
                return FALSE;
!           }
! 
!           /* Get rid of \n and \r */
!           *lf = '\0';
            p = strlen(data);
            if (p > 0 && data[p-1] == '\r') data[p-1] = '\0';
            
            /* End of headers */
            if (*data == '\0') {
!               data = lf + 1;  /* Reset data */
                break;
            }
  
--- 418,439 ----
            int p;
  
            if (!lf) { /* Huh? Invalid data, I think */
+ #if 0
                aplog_error(APLOG_MARK, APLOG_ERR, r->server,
                            "ISA sent invalid headers: %s", r->filename);
                SetLastError(ERROR);    /* XXX: Find right error */
                return FALSE;
! #endif
!             } else
!               /* Get rid of \n and \r */
!               *lf = '\0';
            p = strlen(data);
            if (p > 0 && data[p-1] == '\r') data[p-1] = '\0';
            
            /* End of headers */
            if (*data == '\0') {
!               if (lf)
!                     data = lf + 1;    /* Reset data */
                break;
            }
  
***************
*** 472,478 ****
            }
          
            /* Reset data */
!           data = lf + 1;
        }
        
        /* All the headers should be set now */
--- 474,484 ----
            }
          
            /* Reset data */
!             if (!lf) {
!                 data += p;
!                 break;
!             }
!             data = lf + 1;
        }
        
        /* All the headers should be set now */
%0
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <[EMAIL PROTECTED]> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]



Reply via email to