]> granicus.if.org Git - php/commitdiff
- sapi_header_op(SAPI_HEADER_(REPLACE|ADD), {NULL, 0, 0}) caused HTTP response splitting
authorMichael Wallner <mike@php.net>
Wed, 2 Nov 2005 14:27:02 +0000 (14:27 +0000)
committerMichael Wallner <mike@php.net>
Wed, 2 Nov 2005 14:27:02 +0000 (14:27 +0000)
- sapi_send_headers() already takes care of default_content_type (left over of fix for bug #29983)

main/SAPI.c
sapi/cgi/cgi_main.c

index d2347f050ba6216f53e2c29979ec33e1d313ee5c..86fb2de884d2b65a9b4d221172daddac9fd5ca58 100644 (file)
@@ -567,6 +567,10 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
        case SAPI_HEADER_REPLACE:
        case SAPI_HEADER_ADD: {
                sapi_header_line *p = arg;
+               
+               if (!p->line || !p->line_len) {
+                       return FAILURE;
+               }
                header_line = p->line;
                header_line_len = p->line_len;
                http_response_code = p->response_code;
index 7597bff7a6d26c1bc31c2460c0e9e785fff82d5a..a912da7eff9ee2e4cecd31e68b7f86e0ba6e379a 100644 (file)
@@ -331,21 +331,13 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
                PHPWRITE_H(buf, len);
        }
 
-       if (SG(sapi_headers).send_default_content_type)
-       {
-               char *hd;
-
-               hd = sapi_get_default_content_type(TSRMLS_C);
-               PHPWRITE_H("Content-type: ", sizeof("Content-type: ") - 1);
-               PHPWRITE_H(hd, strlen(hd));
-               PHPWRITE_H("\r\n", 2);
-               efree(hd);
-       }
-
        h = zend_llist_get_first_ex(&sapi_headers->headers, &pos);
        while (h) {
-               PHPWRITE_H(h->header, h->header_len);
-               PHPWRITE_H("\r\n", 2);
+               /* prevent CRLFCRLF */
+               if (h->header_len) {
+                       PHPWRITE_H(h->header, h->header_len);
+                       PHPWRITE_H("\r\n", 2);
+               }
                h = zend_llist_get_next_ex(&sapi_headers->headers, &pos);
        }
        PHPWRITE_H("\r\n", 2);