Skip to content

Commit f932fe5

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #41293 (Fixed creation of HTTP_RAW_POST_DATA when there is no default post handler).
1 parent 636806a commit f932fe5

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
(Ilia)
66
- Fixed altering $this via argument named "this". (Dmitry)
77
- Fixed PHP CLI to use the php.ini from the binary location. (Hannes)
8+
- Fixed bug #41293 (Fixed creation of HTTP_RAW_POST_DATA when there is no
9+
default post handler). (Ilia)
810
- Fixed bug #41287 (Namespace functions don't allow xmlns defintion to be
911
optional). (Rob)
1012
- Fixed bug #41285 (Improved fix for CVE-2007-1887 to work with non-bundled

main/php_content_types.c

+8-11
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,19 @@ static sapi_post_entry php_post_entries[] = {
3737
*/
3838
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
3939
{
40-
char *data = NULL;
41-
int length = 0;
40+
char *data;
41+
int length;
4242

4343
/* $HTTP_RAW_POST_DATA registration */
44-
if(!strcmp(SG(request_info).request_method, "POST")) {
45-
if(NULL == SG(request_info).post_entry && SG(request_info).post_data) {
44+
if (!strcmp(SG(request_info).request_method, "POST")) {
45+
if (NULL == SG(request_info).post_entry) {
4646
/* no post handler registered, so we just swallow the data */
4747
sapi_read_standard_form_data(TSRMLS_C);
48+
}
49+
50+
if (PG(always_populate_raw_post_data) && SG(request_info).post_data) {
4851
length = SG(request_info).post_data_length;
4952
data = estrndup(SG(request_info).post_data, length);
50-
} else if(PG(always_populate_raw_post_data) && SG(request_info).post_data) {
51-
length = SG(request_info).post_data_length;
52-
data = estrndup(SG(request_info).post_data, length);
53-
}
54-
if(data) {
5553
SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);
5654
}
5755
}
@@ -62,11 +60,10 @@ SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
6260
in the long run post handlers should be changed to not touch
6361
request_info.post_data for memory preservation reasons
6462
*/
65-
if(SG(request_info).post_data) {
63+
if (SG(request_info).post_data) {
6664
SG(request_info).raw_post_data = estrndup(SG(request_info).post_data, SG(request_info).post_data_length);
6765
SG(request_info).raw_post_data_length = SG(request_info).post_data_length;
6866
}
69-
7067
}
7168
/* }}} */
7269

0 commit comments

Comments
 (0)