com php-src: Fixed bug #72197 pg_lo_create arbitrary re ad: ext/pgsql/pgsql.c ext/pgsql/tests/bug7219 7.phpt

From: Date: Thu, 12 May 2016 09:40:28 +0000
Subject: com php-src: Fixed bug #72197 pg_lo_create arbitrary re ad: ext/pgsql/pgsql.c ext/pgsql/tests/bug7219 7.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92102@lists.php.net to get a copy of this message
Commit: 7f6e285430e8ec8109085a24978796fc99813498 Author: Anatol Belski <ab@php.net> Thu, 12 May 2016 11:40:28 +0200 Parents: 3797e570b20934236a186acc6dc7eda950c8d034 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7f6e285430e8ec8109085a24978796fc99813498 Log: Fixed bug #72197 pg_lo_create arbitrary read Bugs: https://bugs.php.net/72197 Changed paths: M ext/pgsql/pgsql.c A ext/pgsql/tests/bug72197.phpt Diff: diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 76dfd2a..8f0db26 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -3213,8 +3213,10 @@ PHP_FUNCTION(pg_lo_create) if (pgsql_link == NULL) { link = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(link); - } else { + } else if ((Z_TYPE_P(pgsql_link) == IS_RESOURCE)) { link = Z_RES_P(pgsql_link); + } else { + link = NULL; } if ((pgsql = (PGconn *)zend_fetch_resource2(link, "PostgreSQL link", le_link, le_plink)) == NULL) { diff --git a/ext/pgsql/tests/bug72197.phpt b/ext/pgsql/tests/bug72197.phpt new file mode 100644 index 0000000..da52d8e --- /dev/null +++ b/ext/pgsql/tests/bug72197.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #72197 pg_lo_create arbitrary read +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +/* This shouldn't crash. */ +$var1=-32768; +$var2="12"; +pg_lo_create($var1, $var2); + +/* This should work correctly. */ +include('config.inc'); + +/* Check with explicit link. */ +$conn = pg_connect($conn_str); +pg_query($conn, "BEGIN"); +$oid = pg_lo_create($conn); +var_dump($oid); + +/* Check with default link */ +$oid = pg_lo_create(); +var_dump($oid); + +/* don't commit */ +pg_query($conn, "ROLLBACK"); +pg_close($conn); +?> +==DONE== +--EXPECTF-- +Warning: pg_lo_create(): supplied resource is not a valid PostgreSQL link resource in %sbug72197.php on line %d +int(%d) +int(%d) +==DONE== +

« previous php.cvs (#92102) next »