Bug 40628

Summary: mod_isapi always returns status 500. Bug is in core (libhttpd)
Product: Apache httpd-2 Reporter: Rick Betting <rick>
Component: mod_isapiAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED DUPLICATE    
Severity: normal Keywords: ErrorMessage, PatchAvailable
Priority: P2    
Version: 2.2.2   
Target Milestone: ---   
Hardware: Other   
OS: Windows XP   
Attachments: Corrected return value of funtion line 599 ap_scan_script_header_err_core

Description Rick Betting 2006-09-28 10:09:58 UTC
Every ISAPI returns status 500 "internal server error" and it returns the 
desired content. No real error has occurred.

I could trace it back to: (Source taken from httpd-2.2.3 win32 version)

mod_apache.c line 713: function apr_ssize_t send_response_header

Cid->r->status = ap_scan_script_header_err_strs(cid->r, NULL,
                                   &termch, &termarg, stat, head, NULL);
cid->ecb->dwHttpStatusCode = cid->r->status;

Termarg = 2
Stat = "Status: 200 OK"
Head	= "Content-Type: text/html\r\nContent-Length: 22\r\n\r\n"

Retun value is 0. Should be 200.



util_script.c line 714: function ap_scan_script_header_err_strs

res = ap_scan_script_header_err_core(r, buffer, getsfunc_STRING, 
                                                           (void *) &strs);

Return value is 0. Should be 200.



After successfull execution of function ap_scan_script_header_err_core
util_script.c line 599: function ap_scan_script_header_err_core

return OK;


OK is defined in httpd.h
httpd.h line 445:

#define OK 0			/**< Module has handled this stage. */

HTTP_OK is defined in httpd.h
httpd.h line 462:

#define HTTP_OK                            200


Solution:
The return OK; in util_script.c line 599 should be replaced with return HTTP_OK;
The other possible return in ap_scan_script_header_err_core is 
HTTP_INTERNAL_SERVER_ERROR which is the value 500. (that shows HTTP_ results 
are required in the function.)

Because the return value is 0 mod_apache reads the client content. Later return 
value 0 is recognized as invalid and it reports an internal server error.
Comment 1 Rick Betting 2006-09-28 10:20:16 UTC
Created attachment 18929 [details]
Corrected return value of funtion line 599 ap_scan_script_header_err_core

Corrected return value of funtion line 599 ap_scan_script_header_err_core
Original value was OK new value is HTTP_OK
This solves the ISAPI bug.
Comment 2 Nick Kew 2006-09-28 10:47:00 UTC
That's not a patch.  It's plain source code, and not in a form suitable for 
review.

In any case, you can't just go breaking util_script, which is required by 
*everything* in the CGI family, not just mod_isapi.  There *may* be a bug in 
mod_isapi, but you should check the latest fixes to that, particularly
http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/arch/win32/mod_isapi.c?r1=414238&r2=416272
Comment 3 Rick Betting 2006-09-28 12:06:57 UTC
http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/arch/win32/mod_isapi.c?
r1=414238&r2=416272
Is indeed the solution.
Thank you.
Comment 4 William A. Rowe Jr. 2006-09-28 17:48:21 UTC
Also don't go changing AssignedTo *EVER*.  You broke the linkage for all the
feedback to come to the bugs list.
Comment 5 William A. Rowe Jr. 2006-09-28 18:24:44 UTC

*** This bug has been marked as a duplicate of 40067 ***