Bug 21085

Summary: ab - null pointer when parsing incomplete response
Product: Apache httpd-2 Reporter: Glenn Nielsen <glenn>
Component: Other ModulesAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: CLOSED FIXED    
Severity: normal    
Priority: P3    
Version: 2.0.46   
Target Milestone: ---   
Hardware: All   
OS: other   
Attachments: ab - patch null pointer when parsing a partial response

Description Glenn Nielsen 2003-06-25 15:19:43 UTC
ab can fail due to a null pointer when there is an incomplete response.

A patch will be attached.
Comment 1 Glenn Nielsen 2003-06-25 15:21:27 UTC
Created attachment 6973 [details]
ab - patch null pointer when parsing a partial response
Comment 2 André Malo 2003-06-29 17:54:34 UTC
Fixed in 2.1 and proposed for backport.

I've added another sanity check before committing. The piece of code now looks:

[...]
	    /* check response code */
	    part = strstr(c->cbuff, "HTTP");	/* really HTTP/1.x_ */
            if (part && strlen(part) > strlen("HTTP/1.x_")) {
                strncpy(respcode, (part + strlen("HTTP/1.x_")), 3);
                respcode[3] = '\0';
            }
            else {
                strcpy(respcode, "500");
            }

	    if (respcode[0] != '2') {
[...]

Thanks for your patch!