Commit Graph

305 Commits

Author SHA1 Message Date
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
Nikita Popov
c5d4c45e7d Merge branch 'PHP-7.2' into PHP-7.3 2019-09-17 15:42:58 +02:00
fancyweb
e691a98c1f Fix #76342: file_get_contents waits twice specified timeout 2019-09-17 15:42:29 +02:00
Nikita Popov
1ce830a4aa Fix another pointer indexing UB in http_fopen_wrapper
Only compute the gep after checking whether the pointer is NULL.
2019-09-11 10:31:03 +02:00
Nikita Popov
518c651c66 Avoid pointer UB in strip_header
Don't calculate header_start if lc_header_start is NULL, as we're
going to overflow the address space in that case.
2019-09-03 12:28:18 +02:00
Nikita Popov
b6b98bdf64 Avoid uninit warnin in http_fopen_wrapper
This one looks semi-legit, in case php_stream_eof() returns false
but php_stream_get_line() fails. Not totally sure this cannot
happen, so rewriting to check both conditions at once.
2019-04-12 15:12:39 +02:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Stanislav Malyshev
5913d8cec6 Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix bug #75981: prevent reading beyond buffer start
2018-02-26 22:27:02 -08:00
Stanislav Malyshev
ab9f9b5d3b Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix bug #75981: prevent reading beyond buffer start
2018-02-26 22:26:55 -08:00
Stanislav Malyshev
a6f7760d57 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix bug #75981: prevent reading beyond buffer start
2018-02-26 22:26:50 -08:00
Stanislav Malyshev
dde7a05978 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Fix bug #75981: prevent reading beyond buffer start
2018-02-26 22:26:26 -08:00
Stanislav Malyshev
523f230c83 Fix bug #75981: prevent reading beyond buffer start 2018-02-26 22:25:51 -08:00
Gabriel Caruso
6400264856 Trailing whitespaces
Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
2018-01-03 14:38:00 +01:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Xinchen Hui
ccd4716ec7 year++ 2018-01-02 12:53:31 +08:00
Dmitry Stogov
0f06df310c Turn "php_stream_wrapper"s into constants
Keep non-constant "php_stream_wrapper"s in API functions and callbacks for compatibility.
2017-12-14 22:46:22 +03:00
Dmitry Stogov
83e495e0fd Move constants into read-only data segment 2017-12-14 22:14:36 +03:00
Nikita Popov
a8db62086e Merge branch 'PHP-7.2' 2017-11-17 23:22:12 +01:00
Nikita Popov
31d9287d2b Merge branch 'PHP-7.1' into PHP-7.2 2017-11-17 23:22:07 +01:00
Nikita Popov
092d0922ea Merge branch 'PHP-7.0' into PHP-7.1 2017-11-17 23:21:48 +01:00
Nikita Popov
0e097f2c96 Fixed bug #75535
The sizeof()s for Content-Length and Transfer-Encoding were missing
the trailing ":". Apart from being generally wrong, this no longer
verified that the header actually contains a colon, leading to the
null http_header_value being used.

Additionally, in the interest of being defensive, also make sure
that http_header_value is non-null by setting it to the end of
the header line (effectively an empty string) if there is no colon.
If the following conditions are correct, this value is not going
to be used though.
2017-11-17 23:18:05 +01:00
Anatol Belski
c7bf314b65 Fix unsigned comparison 2017-11-17 18:54:42 +01:00
Dmitry Stogov
49ea143bbd Encapsulate reference-counting primitives.
Prohibit direct update of GC_REFCOUNT(), GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF() shoukf be instead.
Added mactros to validate reference-counting (disabled for now).
These macros are going to be used to eliminate race-condintions during reference-counting on data shared between threads.
2017-10-27 01:28:58 +03:00
Nikita Popov
49d895af86 Merge branch 'PHP-7.2' 2017-09-26 09:21:16 +02:00