aharvey Wed, 15 Sep 2010 10:51:55 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=303391
Log: Fix bug #52849 (GNU MP invalid version match). Bug: http://bugs.php.net/52849 (Assigned) Invalid version match Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/gmp/gmp.c U php/php-src/trunk/ext/gmp/gmp.c Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-09-15 10:29:44 UTC (rev 303390) +++ php/php-src/branches/PHP_5_3/NEWS 2010-09-15 10:51:55 UTC (rev 303391) @@ -21,6 +21,7 @@ - Fixed possible crash in mssql_fetch_batch(). (Kalle) - Fixed inconsistent backlog default value (-1) in FPM on many systems. (fat) +- Fixed bug #52849 (GNU MP invalid version match). (Adam) - Fixed bug #52843 (Segfault when optional parameters are not passed in to mssql_connect). (Felipe) - Fixed bug #52827 (cURL leaks handle and causes assertion error Modified: php/php-src/branches/PHP_5_3/ext/gmp/gmp.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/gmp/gmp.c 2010-09-15 10:29:44 UTC (rev 303390) +++ php/php-src/branches/PHP_5_3/ext/gmp/gmp.c 2010-09-15 10:51:55 UTC (rev 303391) @@ -316,6 +316,14 @@ #define GMP_ROUND_PLUSINF 1 #define GMP_ROUND_MINUSINF 2 +/* The maximum base for input and output conversions is 62 from GMP 4.2 + * onwards. */ +#if (__GNU_MP_VERSION >= 5) || (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2) +# define MAX_BASE 62 +#else +# define MAX_BASE 36 +#endif + /* {{{ gmp_emalloc */ static void *gmp_emalloc(size_t size) @@ -753,12 +761,8 @@ return; } -#if (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2) - if (base && (base < 2 || base > 62)) { -#else - if (base && (base < 2 || base > 36)) { -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and 36)", base); + if (base && (base < 2 || base > MAX_BASE)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d)", base, MAX_BASE); RETURN_FALSE; } @@ -807,12 +811,15 @@ return; } -#if __GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2 - if ((base < 2 && base > -2) || base > 62 || base < -36) { +#if MAX_BASE == 62 + /* Although the maximum base in general in GMP >= 4.2 is 62, mpz_get_str() + * is explicitly limited to -36 when dealing with negative bases. */ + if ((base < 2 && base > -2) || base > MAX_BASE || base < -36) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d or -2 and -36)", base, MAX_BASE); #else - if (base < 2 || base > 36) { + if (base < 2 || base > MAX_BASE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d)", base, MAX_BASE); #endif - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld", base); RETURN_FALSE; } Modified: php/php-src/trunk/ext/gmp/gmp.c =================================================================== --- php/php-src/trunk/ext/gmp/gmp.c 2010-09-15 10:29:44 UTC (rev 303390) +++ php/php-src/trunk/ext/gmp/gmp.c 2010-09-15 10:51:55 UTC (rev 303391) @@ -316,6 +316,14 @@ #define GMP_ROUND_PLUSINF 1 #define GMP_ROUND_MINUSINF 2 +/* The maximum base for input and output conversions is 62 from GMP 4.2 + * onwards. */ +#if (__GNU_MP_VERSION >= 5) || (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2) +# define MAX_BASE 62 +#else +# define MAX_BASE 36 +#endif + /* {{{ gmp_emalloc */ static void *gmp_emalloc(size_t size) @@ -753,12 +761,8 @@ return; } -#if (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2) - if (base && (base < 2 || base > 62)) { -#else - if (base && (base < 2 || base > 36)) { -#endif - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and 36)", base); + if (base && (base < 2 || base > MAX_BASE)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d)", base, MAX_BASE); RETURN_FALSE; } @@ -807,12 +811,15 @@ return; } -#if __GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2 - if ((base < 2 && base > -2) || base > 62 || base < -36) { +#if MAX_BASE == 62 + /* Although the maximum base in general in GMP >= 4.2 is 62, mpz_get_str() + * is explicitly limited to -36 when dealing with negative bases. */ + if ((base < 2 && base > -2) || base > MAX_BASE || base < -36) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d or -2 and -36)", base, MAX_BASE); #else - if (base < 2 || base > 36) { + if (base < 2 || base > MAX_BASE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and %d)", base, MAX_BASE); #endif - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld", base); RETURN_FALSE; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php