com php-src: Fixed Bug #69667 segfault in php_pgsql_meta_ data: ext/pgsql/pg_insert_002.phpt ext/pgsql/ pgsql.c

From: Date: Wed, 20 May 2015 06:08:41 +0000
Subject: com php-src: Fixed Bug #69667 segfault in php_pgsql_meta_ data: ext/pgsql/pg_insert_002.phpt ext/pgsql/ pgsql.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-86810@lists.php.net to get a copy of this message
Commit: 2cc4e69cc6d8dbc4b3568ad3dd583324a7c11d64 Author: Remi Collet <remi@php.net> Wed, 20 May 2015 08:08:41 +0200 Parents: 58e5e006e540dbec3f4c17cbd8f640e5f03a38d6 Branches: PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2cc4e69cc6d8dbc4b3568ad3dd583324a7c11d64 Log: Fixed Bug #69667 segfault in php_pgsql_meta_data Incomplete fix for #68741 Bugs: https://bugs.php.net/69667 https://bugs.php.net/68741 Changed paths: A ext/pgsql/pg_insert_002.phpt M ext/pgsql/pgsql.c Diff: diff --git a/ext/pgsql/pg_insert_002.phpt b/ext/pgsql/pg_insert_002.phpt new file mode 100644 index 0000000..1393f5f --- /dev/null +++ b/ext/pgsql/pg_insert_002.phpt @@ -0,0 +1,27 @@ +--TEST-- +PostgreSQL pg_select() - basic test using schema +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php + +include('config.inc'); + +$conn = pg_connect($conn_str); + +foreach (array('', '.', '..') as $table) { + var_dump(pg_insert($conn, '', array('id' => 1, 'id2' => 1))); +} +?> +Done +--EXPECTF-- + +Warning: pg_insert(): The table name must be specified in %s on line %d +bool(false) + +Warning: pg_insert(): The table name must be specified in %s on line %d +bool(false) + +Warning: pg_insert(): The table name must be specified in %s on line %d +bool(false) +Done \ No newline at end of file diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 23d55cb..5418b3c 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -5120,7 +5120,11 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z src = estrdup(table_name); tmp_name = php_strtok_r(src, ".", &tmp_name2); - + if (!tmp_name) { + efree(src); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The table name must be specified"); + return FAILURE; + } if (!tmp_name2 || !*tmp_name2) { /* Default schema */ tmp_name2 = tmp_name; @@ -6130,7 +6134,8 @@ static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, ulong opt T static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const char *table) { - char *table_copy, *escaped, *token, *tmp; + char *table_copy, *escaped, *tmp; + const char *token; size_t len; /* schame.table should be "schame"."table" */

« previous php.cvs (#86810) next »