From: Ilia Alshanetsky Date: Tue, 15 Nov 2011 18:02:58 +0000 (+0000) Subject: Fixed bug #60244 (pg_fetch_* functions do not validate that row param is >0). X-Git-Tag: php-5.5.0alpha1~887 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32c4c239c0c499708287c8e9a472823c56e5b3de;p=php Fixed bug #60244 (pg_fetch_* functions do not validate that row param is >0). --- diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index a82271776c..8f979b7391 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2452,6 +2452,10 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, } else { convert_to_long(zrow); row = Z_LVAL_P(zrow); + if (row < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The row parameter must be greater or equal to zero"); + RETURN_FALSE; + } } use_row = ZEND_NUM_ARGS() > 1 && row != -1; diff --git a/ext/pgsql/tests/bug60244.phpt b/ext/pgsql/tests/bug60244.phpt new file mode 100644 index 0000000000..94568b6031 --- /dev/null +++ b/ext/pgsql/tests/bug60244.phpt @@ -0,0 +1,57 @@ +--TEST-- +Bug #60244 (pg_fetch_* functions do not validate that row param is >0) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: pg_fetch_array(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d +bool(false) + +Warning: pg_fetch_assoc(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d +bool(false) + +Warning: pg_fetch_object(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d +bool(false) + +Warning: pg_fetch_row(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d +bool(false) +array(2) { + [0]=> + string(1) "a" + ["?column?"]=> + string(1) "a" +} +array(1) { + ["?column?"]=> + string(1) "a" +} +object(stdClass)#1 (1) { + ["?column?"]=> + string(1) "a" +} +array(1) { + [0]=> + string(1) "a" +}