Skip to content

Commit 6de9152

Browse files
committed
Merge branch 'PHP-5.6' of https://git.php.net/push/php-src into PHP-5.6
* 'PHP-5.6' of https://git.php.net/push/php-src: Fix crashes in GMP serialize/unserialize enable gmp for tests
2 parents 0edf1d4 + c18ae51 commit 6de9152

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ PHP NEWS
4343
. Fixed bug #66908 (php-fpm reload leaks epoll_create() file descriptor).
4444
(Julio Pintos)
4545

46+
- GMP:
47+
. Fixed crashes in serialize/unserialize. (Stas)
48+
4649
- JSON:
4750
. Fixed bug #66021 (Blank line inside empty array/object when
4851
JSON_PRETTY_PRINT is set). (Kevin Israel)

ext/gmp/gmp.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -575,22 +575,20 @@ static int gmp_serialize(zval *object, unsigned char **buffer, zend_uint *buf_le
575575
mpz_ptr gmpnum = GET_GMP_FROM_ZVAL(object);
576576
smart_str buf = {0};
577577
zval zv, *zv_ptr = &zv;
578-
php_serialize_data_t *serialize_data = (php_serialize_data_t *) data;
579-
580-
PHP_VAR_SERIALIZE_INIT(*serialize_data);
578+
php_serialize_data_t serialize_data = (php_serialize_data_t) data;
581579

580+
PHP_VAR_SERIALIZE_INIT(serialize_data);
582581
INIT_PZVAL(zv_ptr);
583-
582+
584583
gmp_strval(zv_ptr, gmpnum, 10);
585-
php_var_serialize(&buf, &zv_ptr, serialize_data TSRMLS_CC);
584+
php_var_serialize(&buf, &zv_ptr, &serialize_data TSRMLS_CC);
586585
zval_dtor(zv_ptr);
587586

588587
Z_ARRVAL_P(zv_ptr) = zend_std_get_properties(object TSRMLS_CC);
589588
Z_TYPE_P(zv_ptr) = IS_ARRAY;
590-
php_var_serialize(&buf, &zv_ptr, serialize_data TSRMLS_CC);
591-
592-
PHP_VAR_SERIALIZE_DESTROY(*serialize_data);
589+
php_var_serialize(&buf, &zv_ptr, &serialize_data TSRMLS_CC);
593590

591+
PHP_VAR_SERIALIZE_DESTROY(serialize_data);
594592
*buffer = (unsigned char *) buf.c;
595593
*buf_len = buf.len;
596594

@@ -604,17 +602,16 @@ static int gmp_unserialize(zval **object, zend_class_entry *ce, const unsigned c
604602
const unsigned char *p, *max;
605603
zval zv, *zv_ptr = &zv;
606604
int retval = FAILURE;
607-
php_unserialize_data_t *unserialize_data = (php_unserialize_data_t *) data;
608-
609-
PHP_VAR_UNSERIALIZE_INIT(*unserialize_data);
605+
php_unserialize_data_t unserialize_data = (php_unserialize_data_t) data;
610606

607+
PHP_VAR_UNSERIALIZE_INIT(unserialize_data);
611608
gmp_create_ex(*object, &gmpnum TSRMLS_CC);
612609

613610
p = buf;
614611
max = buf + buf_len;
615612

616613
INIT_ZVAL(zv);
617-
if (!php_var_unserialize(&zv_ptr, &p, max, unserialize_data TSRMLS_CC)
614+
if (!php_var_unserialize(&zv_ptr, &p, max, &unserialize_data TSRMLS_CC)
618615
|| Z_TYPE_P(zv_ptr) != IS_STRING
619616
|| convert_to_gmp(gmpnum, zv_ptr, 10 TSRMLS_CC) == FAILURE
620617
) {
@@ -624,7 +621,7 @@ static int gmp_unserialize(zval **object, zend_class_entry *ce, const unsigned c
624621
zval_dtor(&zv);
625622

626623
INIT_ZVAL(zv);
627-
if (!php_var_unserialize(&zv_ptr, &p, max, unserialize_data TSRMLS_CC)
624+
if (!php_var_unserialize(&zv_ptr, &p, max, &unserialize_data TSRMLS_CC)
628625
|| Z_TYPE_P(zv_ptr) != IS_ARRAY
629626
) {
630627
zend_throw_exception(NULL, "Could not unserialize properties", 0 TSRMLS_CC);
@@ -641,7 +638,7 @@ static int gmp_unserialize(zval **object, zend_class_entry *ce, const unsigned c
641638
retval = SUCCESS;
642639
exit:
643640
zval_dtor(&zv);
644-
PHP_VAR_UNSERIALIZE_DESTROY(*unserialize_data);
641+
PHP_VAR_UNSERIALIZE_DESTROY(unserialize_data);
645642
return retval;
646643
}
647644
/* }}} */

travis/compile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
--enable-sockets \
3535
--with-bz2 \
3636
--with-openssl \
37+
--with-gmp \
3738
--enable-bcmath
3839
make --quiet

0 commit comments

Comments
 (0)