]> granicus.if.org Git - php/commitdiff
Fix headers generated by phar
authorNikita Popov <nikic@php.net>
Sat, 18 Feb 2012 13:39:13 +0000 (13:39 +0000)
committerNikita Popov <nikic@php.net>
Sat, 18 Feb 2012 13:39:13 +0000 (13:39 +0000)
sapi_header_line.line_len is the length without null terminator, so one has to
take sizeof - 1. This fixes some test failures as the NUL bytes were causing
warnings.

Needs to be merged to 5.4.

ext/phar/phar_object.c

index 684b03a43e43c48eda15cdfc17e5a7a26b7c49f9..0335615ea470419557065ca4a7a108b267c9844f 100644 (file)
@@ -427,7 +427,7 @@ static void phar_do_403(char *entry, int entry_len TSRMLS_DC) /* {{{ */
        sapi_header_line ctr = {0};
 
        ctr.response_code = 403;
-       ctr.line_len = sizeof("HTTP/1.0 403 Access Denied");
+       ctr.line_len = sizeof("HTTP/1.0 403 Access Denied")-1;
        ctr.line = "HTTP/1.0 403 Access Denied";
        sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
        sapi_send_headers(TSRMLS_C);
@@ -452,7 +452,7 @@ static void phar_do_404(phar_archive_data *phar, char *fname, int fname_len, cha
        }
 
        ctr.response_code = 404;
-       ctr.line_len = sizeof("HTTP/1.0 404 Not Found")+1;
+       ctr.line_len = sizeof("HTTP/1.0 404 Not Found")-1;
        ctr.line = "HTTP/1.0 404 Not Found";
        sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
        sapi_send_headers(TSRMLS_C);
@@ -891,7 +891,7 @@ PHP_METHOD(Phar, webPhar)
                        char *tmp = NULL, sa = '\0';
                        sapi_header_line ctr = {0};
                        ctr.response_code = 301;
-                       ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")+1;
+                       ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")-1;
                        ctr.line = "HTTP/1.1 301 Moved Permanently";
                        sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);