Commit graph

333 commits

Author SHA1 Message Date
Jakub Zelenka
acf2f4988a
Merge branch 'PHP-8.2' into PHP-8.3 2025-03-11 22:09:00 +01:00
Jakub Zelenka
4af1830356
Merge branch 'PHP-8.1' into PHP-8.2 2025-03-11 21:57:33 +01:00
Jakub Zelenka
41d49abbd9
Fix GHSA-hgf5-96fm-v528: http user header check of crlf 2025-03-11 21:50:16 +01:00
Jakub Zelenka
ac1a054bb3
Fix GHSA-52jp-hrpf-2jff: http redirect location truncation
It converts the allocation of location to be on heap instead of stack
and errors if the location length is greater than 8086 bytes.
2025-03-11 21:50:16 +01:00
Jakub Zelenka
0548c4c175
Fix GHSA-pcmh-g36c-qc44: http headers without colon
The header line must contain colon otherwise it is invalid and it needs
to fail.

Reviewed-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-03-11 21:50:16 +01:00
Jakub Zelenka
d20b4c97a9
Fix GHSA-ghsa-v8xr-gpvj-cx9g: http header folding
This adds HTTP header folding support for HTTP wrapper response
headers.

Reviewed-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-03-11 21:50:16 +01:00
David Carlier
301b8e24c1
Fix GH-16809: fopen HTTP wrapper timeout stream context option overflow.
close GH-16810
2024-12-08 20:29:57 +00:00
Jakub Zelenka
ffff27f734
Merge branch 'PHP-8.2' into PHP-8.3 2024-11-20 11:12:19 +01:00
Jakub Zelenka
d7fe40868e
Fix GHSA-c5f2-jwm7-mmq2: stream HTTP fulluri CRLF injection 2024-11-20 11:06:02 +01:00
Jakub Zelenka
426a6d4539
Fix GHSA-c5f2-jwm7-mmq2: stream HTTP fulluri CRLF injection 2024-11-17 19:29:45 +01:00
Niels Dossche
c26d1a36e2
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15034: Integer overflow on stream_notification_callback byte_max parameter with files bigger than 2GB
2024-07-21 22:02:47 +02:00
Niels Dossche
cfcc2a3fda
Fix GH-15034: Integer overflow on stream_notification_callback byte_max parameter with files bigger than 2GB
We were using atoi, which is only for integers. When the size does not
fit in an integer this breaks. Use ZEND_STRTOUL instead. Also make sure
invalid data isn't accidentally parsed into a file size.

Closes GH-15035.
2024-07-21 22:02:11 +02:00
George Peter Banyard
810507ab1b http_fopen_wrapper: fix [-Wanalyzer-deref-before-check]
warning: check of ‘*resource.scheme’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]
  186 |                 use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) && ZSTR_VAL(resource->scheme)[4] == 's';
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Although resource->scheme is already dereferenced on line 163 in the IF condition
2023-06-02 20:33:20 +01:00
Niels Dossche
afcf97b2a4 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11274: POST/PATCH request via file_get_contents + stream_context_create switches to GET after a HTTP 308 redirect
2023-05-19 23:46:47 +02:00
Niels Dossche
45897f592c Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11274: POST/PATCH request via file_get_contents + stream_context_create switches to GET after a HTTP 308 redirect
2023-05-19 23:43:02 +02:00
Niels Dossche
1ede3137c9 Fix GH-11274: POST/PATCH request via file_get_contents + stream_context_create switches to GET after a HTTP 308 redirect
RFC 7231 states that status code 307 should keep the POST method upon
redirect. RFC 7538 does the same for code 308. Although it's not
mandated by the RFCs that PATCH is also kept (we can choose), it seems
like keeping PATCH will be the most consistent and understandable behaviour.

This patch also changes an existing test because it was testing for the
wrong behaviour.

Closes GH-11275.
2023-05-19 23:37:20 +02:00
nielsdos
42aaac3525 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10031: [Stream] STREAM_NOTIFY_PROGRESS over HTTP emitted irregularly for last chunk of data
2023-05-05 19:30:05 +02:00
nielsdos
1fc18a84d9 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10031: [Stream] STREAM_NOTIFY_PROGRESS over HTTP emitted irregularly for last chunk of data
2023-05-05 19:28:01 +02:00
Niels Dossche
b33fbbfe3d Fix GH-10031: [Stream] STREAM_NOTIFY_PROGRESS over HTTP emitted irregularly for last chunk of data
It's possible that the server already sent in more data than just the headers.
Since the stream only accepts progress increments after the headers are
processed, the already read data is never added to the process.
We account for this by adjusting the progress counter by the difference of
already read header data and the body.

For the test:
Co-authored-by: aetonsi <18366087+aetonsi@users.noreply.github.com>

Closes GH-10492.
2023-05-05 19:26:44 +02:00
Javier Eguiluz
732d92c0e5
[skip ci] Fix various typos and grammar issues (#11143) 2023-04-28 11:05:32 +02:00
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Christoph M. Becker
45a3f4cab0
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-9316: $http_response_header is wrong for long status line
2022-08-18 12:31:56 +02:00
Christoph M. Becker
5d196d9e7c
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9316: $http_response_header is wrong for long status line
2022-08-18 12:30:45 +02:00
Christoph M. Becker
72da418719
Fix GH-9316: $http_response_header is wrong for long status line
While the reason-phrase in a HTTP response status line is usually
short, there is no actual limit specified by the RFCs.  As such, we
must not assume that the line fits into the buffer (which is currently
128 bytes large).

Since there is no real need to present the complete status line, we
simply read and discard the rest of a long line.

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>

Closes GH-9319.
2022-08-18 12:27:54 +02:00
George Peter Banyard
5171cb435a Fix [-Wundef] warnings in standard extension 2022-04-01 15:48:41 +01:00
Tim Starling
c96be7b8f2 Use ASCII lower case for misc case folding
Use ASCII case conversion instead of locale-dependent case conversion in
the following places:

* grapheme_stripos() and grapheme_strripos() in the "fast" path
* ldap_get_entries()
* oci_pconnect() for case folding of parameters when constructing a key
  into the connection or session pool
* SoapClient: case folding of function names
* get_meta_tags(): case conversion of property names
* http stream wrapper: header names
* phpinfo(): anchor names
* php_verror(): docref URLs
* rfc1867.c: Content-Type boundary parameter name
* streams.c: stream protocol names

Using locale-dependent case folding for these cases is either
unnecessary or actively incorrect. These functions could have
misbehaved when used with certain locales (e.g. Turkish).

Closes GH-7511.
2021-09-24 09:20:08 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
twosee
1215563288
Micro optimizations for http_fopen_wrapper.c (#6864) 2021-04-15 16:34:17 +08:00
Christoph M. Becker
8d58504035 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
2021-03-08 14:52:45 +01:00
Christoph M. Becker
3880b8785b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
2021-03-08 14:51:45 +01:00
manuel
5787f91c55 Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
Don't wait for further responses after a HTTP 101 (Switching Protocols) response

Closes GH-6730.
2021-03-08 14:36:31 +01:00
Christoph M. Becker
8162abeb17 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #78719: http wrapper silently ignores long Location headers
2021-03-03 10:48:43 +01:00
Christoph M. Becker
90b24401d6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #78719: http wrapper silently ignores long Location headers
2021-03-03 10:47:51 +01:00
Christoph M. Becker
51e2015af3 Fix #78719: http wrapper silently ignores long Location headers
When opening HTTP streams, and reading the headers, we currently
discard header lines longer than `HTTP_HEADER_BLOCK_SIZE` (1024 bytes).
While this is not generally forbidden by RFC 7230, section 3.2.5, it
is not generally allowed either, since that may change the "message
framing or response semantics".

We thus fix this by allowing arbitrarily long header lines.

Closes GH-6720.
2021-03-03 10:45:25 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Dmitry Stogov
2693f799be Don't force rebuild of symbol table, when populating $http_response_header variable by the HTTP stream wrapper 2020-10-28 12:59:00 +03:00
Nikita Popov
1c157d3fa2 Fixed bug #80256
Remove the transfer_encoding stream filter immediately when we
destroy the old stream, to make sure it doesn't get attached to
the new stream.
2020-10-20 15:35:41 +02:00
Rowan Tommins
f9f769d4b9 Make http stream wrapper advertise HTTP/1.1 by default
In practice, we always act as an HTTP/1.1 client, for compatibility
with servers which ignore protocol version. Sending the version in
the request will avoid problems with servers which don't ignore it.

HTTP/1.0 can still be forced using a stream context option.

Closes GH-5899.
2020-08-03 16:30:09 +02:00
Nikita Popov
f69bad872a Merge branch 'PHP-7.4'
* PHP-7.4:
  Don't treat any WS as start of header
2020-02-24 10:20:49 +01:00
Nikita Popov
c5128fb7fc Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Don't treat any WS as start of header
2020-02-24 10:20:43 +01:00
Nikita Popov
56cdbe63c2 Don't treat any WS as start of header
Check that the header occurs after \n, not other whitespace
characters.
2020-02-24 10:20:33 +01:00
Nikita Popov
8d451fd24e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Reduce code duplication in HTTP header checks
2020-02-24 10:03:30 +01:00
Nikita Popov
3d9c02364d Reduce code duplication in HTTP header checks 2020-02-24 10:03:05 +01:00
Nikita Popov
cc704f5bb6 Reduce code duplication in HTTP header checks 2020-02-24 09:58:29 +01:00
Nikita Popov
ce2abdd42e Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixes #79265: Improper injection of Host header when using fopen for http requests
2020-02-24 09:51:55 +01:00
Nikita Popov
e855b286c8 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixes #79265: Improper injection of Host header when using fopen for http requests
2020-02-24 09:51:36 +01:00
Miguel Xavier Penha Neto
d0d60503b5 Fixes #79265: Improper injection of Host header when using fopen for http requests
Check all occurrences of the string "host:" (and other headers),
not just the first one.
2020-02-24 09:50:32 +01:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Nikita Popov
b50a90867a Merge branch 'PHP-7.3' into PHP-7.4 2019-09-17 15:43:35 +02:00