Skip to content

Commit 2e2636d

Browse files
committed
Merge branch 'PHP-5.5' of https://git.php.net/repository/php-src into PHP-5.5
* 'PHP-5.5' of https://git.php.net/repository/php-src: typo: really fix bug #51936 Crash with clone xmlreader fix bug #59613 (Crash with clone XMLReader) Fix Bug #60633 build warning in bcmath fix bug #65808 the socket_connect() won't work with IPv6 address 5.4.22-dev now
2 parents 6cd0bd8 + 92fd085 commit 2e2636d

File tree

6 files changed

+67
-20
lines changed

6 files changed

+67
-20
lines changed

ext/bcmath/libbcmath/src/recmul.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
183183
int full_scale TSRMLS_DC)
184184
{
185185
bc_num u0, u1, v0, v1;
186-
int u0len, v0len;
187186
bc_num m1, m2, m3, d1, d2;
188187
int n, prodlen, m1zero;
189188
int d1len, d2len;
@@ -216,10 +215,8 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
216215
}
217216
_bc_rm_leading_zeros (u1);
218217
_bc_rm_leading_zeros (u0);
219-
u0len = u0->n_len;
220218
_bc_rm_leading_zeros (v1);
221219
_bc_rm_leading_zeros (v0);
222-
v0len = v0->n_len;
223220

224221
m1zero = bc_is_zero(u1 TSRMLS_CC) || bc_is_zero(v1 TSRMLS_CC);
225222

ext/sockets/multicast.c

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ static const char *_php_source_op_to_string(enum source_op sop);
6363
static int _php_source_op_to_ipv4_op(enum source_op sop);
6464
#endif
6565

66+
int php_string_to_if_index(const char *val, unsigned *out TSRMLS_DC)
67+
{
68+
#if HAVE_IF_NAMETOINDEX
69+
unsigned int ind;
70+
71+
ind = if_nametoindex(val);
72+
if (ind == 0) {
73+
php_error_docref(NULL TSRMLS_CC, E_WARNING,
74+
"no interface with name \"%s\" could be found", val);
75+
return FAILURE;
76+
} else {
77+
*out = ind;
78+
return SUCCESS;
79+
}
80+
#else
81+
php_error_docref(NULL TSRMLS_CC, E_WARNING,
82+
"this platform does not support looking up an interface by "
83+
"name, an integer interface index must be supplied instead");
84+
return FAILURE;
85+
#endif
86+
}
87+
6688
static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
6789
{
6890
int ret;
@@ -78,31 +100,17 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
78100
ret = SUCCESS;
79101
}
80102
} else {
81-
#if HAVE_IF_NAMETOINDEX
82-
unsigned int ind;
83103
zval_add_ref(&val);
84104
convert_to_string_ex(&val);
85-
ind = if_nametoindex(Z_STRVAL_P(val));
86-
if (ind == 0) {
87-
php_error_docref(NULL TSRMLS_CC, E_WARNING,
88-
"no interface with name \"%s\" could be found", Z_STRVAL_P(val));
89-
ret = FAILURE;
90-
} else {
91-
*out = ind;
92-
ret = SUCCESS;
93-
}
105+
ret = php_string_to_if_index(Z_STRVAL_P(val), out TSRMLS_CC);
94106
zval_ptr_dtor(&val);
95-
#else
96-
php_error_docref(NULL TSRMLS_CC, E_WARNING,
97-
"this platform does not support looking up an interface by "
98-
"name, an integer interface index must be supplied instead");
99-
ret = FAILURE;
100-
#endif
101107
}
102108

103109
return ret;
104110
}
105111

112+
113+
106114
static int php_get_if_index_from_array(const HashTable *ht, const char *key,
107115
php_socket *sock, unsigned int *if_index TSRMLS_DC)
108116
{

ext/sockets/multicast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ int php_add4_to_if_index(
6565
php_socket *php_sock,
6666
unsigned *if_index TSRMLS_DC);
6767

68+
int php_string_to_if_index(const char *val, unsigned *out TSRMLS_DC);
69+
6870
int php_mcast_join(
6971
php_socket *sock,
7072
int level,

ext/sockets/sockaddr_conv.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
1818
struct addrinfo hints;
1919
struct addrinfo *addrinfo = NULL;
2020
#endif
21+
char *scope = strchr(string, '%');
2122

2223
if (inet_pton(AF_INET6, string, &tmp)) {
2324
memcpy(&(sin6->sin6_addr.s6_addr), &(tmp.s6_addr), sizeof(struct in6_addr));
@@ -53,6 +54,22 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
5354

5455
}
5556

57+
if (scope++) {
58+
long lval = 0;
59+
double dval = 0;
60+
unsigned scope_id = 0;
61+
62+
if (IS_LONG == is_numeric_string(scope, strlen(scope), &lval, &dval, 0)) {
63+
if (lval > 0 && lval <= UINT_MAX) {
64+
scope_id = lval;
65+
}
66+
} else {
67+
php_string_to_if_index(scope, &scope_id TSRMLS_CC);
68+
}
69+
70+
sin6->sin6_scope_id = scope_id;
71+
}
72+
5673
return 1;
5774
}
5875
/* }}} */

ext/xmlreader/php_xmlreader.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,7 @@ PHP_MINIT_FUNCTION(xmlreader)
13201320
xmlreader_object_handlers.read_property = xmlreader_read_property;
13211321
xmlreader_object_handlers.write_property = xmlreader_write_property;
13221322
xmlreader_object_handlers.get_property_ptr_ptr = xmlreader_get_property_ptr_ptr;
1323+
xmlreader_object_handlers.clone_obj = NULL;
13231324

13241325
INIT_CLASS_ENTRY(ce, "XMLReader", xmlreader_functions);
13251326
ce.create_object = xmlreader_objects_new;

ext/xmlreader/tests/bug51936.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #51936 (Crash with clone XMLReader)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded("xmlreader") or die("skip requires xmlreader");
6+
?>
7+
--FILE--
8+
<?php
9+
echo "Test\n";
10+
11+
$xmlreader = new XMLReader();
12+
$xmlreader->xml("<a><b/></a>");
13+
14+
$xmlreader->next();
15+
$xmlreader2 = clone $xmlreader;
16+
$xmlreader2->next();
17+
?>
18+
Done
19+
--EXPECTF--
20+
Test
21+
22+
Fatal error: Trying to clone an uncloneable object of class XMLReader in %s on line %d

0 commit comments

Comments
 (0)