* 'master' 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
This commit is contained in:
Christopher Jones 2013-10-03 05:41:05 -07:00
commit 333539b5fc
6 changed files with 67 additions and 20 deletions

View File

@ -183,7 +183,6 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
int full_scale TSRMLS_DC)
{
bc_num u0, u1, v0, v1;
int u0len, v0len;
bc_num m1, m2, m3, d1, d2;
int n, prodlen, m1zero;
int d1len, d2len;
@ -216,10 +215,8 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
}
_bc_rm_leading_zeros (u1);
_bc_rm_leading_zeros (u0);
u0len = u0->n_len;
_bc_rm_leading_zeros (v1);
_bc_rm_leading_zeros (v0);
v0len = v0->n_len;
m1zero = bc_is_zero(u1 TSRMLS_CC) || bc_is_zero(v1 TSRMLS_CC);

View File

@ -63,6 +63,28 @@ static const char *_php_source_op_to_string(enum source_op sop);
static int _php_source_op_to_ipv4_op(enum source_op sop);
#endif
int php_string_to_if_index(const char *val, unsigned *out TSRMLS_DC)
{
#if HAVE_IF_NAMETOINDEX
unsigned int ind;
ind = if_nametoindex(val);
if (ind == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"no interface with name \"%s\" could be found", val);
return FAILURE;
} else {
*out = ind;
return SUCCESS;
}
#else
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"this platform does not support looking up an interface by "
"name, an integer interface index must be supplied instead");
return FAILURE;
#endif
}
static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
{
int ret;
@ -78,31 +100,17 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
ret = SUCCESS;
}
} else {
#if HAVE_IF_NAMETOINDEX
unsigned int ind;
zval_add_ref(&val);
convert_to_string_ex(&val);
ind = if_nametoindex(Z_STRVAL_P(val));
if (ind == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"no interface with name \"%s\" could be found", Z_STRVAL_P(val));
ret = FAILURE;
} else {
*out = ind;
ret = SUCCESS;
}
ret = php_string_to_if_index(Z_STRVAL_P(val), out TSRMLS_CC);
zval_ptr_dtor(&val);
#else
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"this platform does not support looking up an interface by "
"name, an integer interface index must be supplied instead");
ret = FAILURE;
#endif
}
return ret;
}
static int php_get_if_index_from_array(const HashTable *ht, const char *key,
php_socket *sock, unsigned int *if_index TSRMLS_DC)
{

View File

@ -65,6 +65,8 @@ int php_add4_to_if_index(
php_socket *php_sock,
unsigned *if_index TSRMLS_DC);
int php_string_to_if_index(const char *val, unsigned *out TSRMLS_DC);
int php_mcast_join(
php_socket *sock,
int level,

View File

@ -18,6 +18,7 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
struct addrinfo hints;
struct addrinfo *addrinfo = NULL;
#endif
char *scope = strchr(string, '%');
if (inet_pton(AF_INET6, string, &tmp)) {
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_
}
if (scope++) {
long lval = 0;
double dval = 0;
unsigned scope_id = 0;
if (IS_LONG == is_numeric_string(scope, strlen(scope), &lval, &dval, 0)) {
if (lval > 0 && lval <= UINT_MAX) {
scope_id = lval;
}
} else {
php_string_to_if_index(scope, &scope_id TSRMLS_CC);
}
sin6->sin6_scope_id = scope_id;
}
return 1;
}
/* }}} */

View File

@ -1320,6 +1320,7 @@ PHP_MINIT_FUNCTION(xmlreader)
xmlreader_object_handlers.read_property = xmlreader_read_property;
xmlreader_object_handlers.write_property = xmlreader_write_property;
xmlreader_object_handlers.get_property_ptr_ptr = xmlreader_get_property_ptr_ptr;
xmlreader_object_handlers.clone_obj = NULL;
INIT_CLASS_ENTRY(ce, "XMLReader", xmlreader_functions);
ce.create_object = xmlreader_objects_new;

View File

@ -0,0 +1,22 @@
--TEST--
Bug #51936 (Crash with clone XMLReader)
--SKIPIF--
<?php
extension_loaded("xmlreader") or die("skip requires xmlreader");
?>
--FILE--
<?php
echo "Test\n";
$xmlreader = new XMLReader();
$xmlreader->xml("<a><b/></a>");
$xmlreader->next();
$xmlreader2 = clone $xmlreader;
$xmlreader2->next();
?>
Done
--EXPECTF--
Test
Fatal error: Trying to clone an uncloneable object of class XMLReader in %s on line %d