com php-src: Fixed bug #75671 pg_version() crashes wh en called on a connection to cockroach: ext/pgs ql/pgsql.c

From: Date: Fri, 15 Dec 2017 14:33:14 +0000
Subject: com php-src: Fixed bug #75671 pg_version() crashes wh en called on a connection to cockroach: ext/pgs ql/pgsql.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100597@lists.php.net to get a copy of this message
Commit: acf1472ffde08a514fa44ef4b5baa0c67ae1b3f2 Author: Anatol Belski <ab@php.net> Fri, 15 Dec 2017 15:33:14 +0100 Parents: fd81881e5edd95842970032ef2be74f09bfb82d2 Branches: PHP-7.1 PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=acf1472ffde08a514fa44ef4b5baa0c67ae1b3f2 Log: Fixed bug #75671 pg_version() crashes when called on a connection to cockroach Bugs: https://bugs.php.net/75671 Changed paths: M ext/pgsql/pgsql.c Diff: diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 53d1c5b..3a99adc 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1659,26 +1659,21 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type /* 8.0 or grater supports protorol version 3 */ char *tmp; add_assoc_string(return_value, "server", (char*)PQparameterStatus(pgsql, "server_version")); - tmp = (char*)PQparameterStatus(pgsql, "server_encoding"); - add_assoc_string(return_value, "server_encoding", tmp); - tmp = (char*)PQparameterStatus(pgsql, "client_encoding"); - add_assoc_string(return_value, "client_encoding", tmp); - tmp = (char*)PQparameterStatus(pgsql, "is_superuser"); - add_assoc_string(return_value, "is_superuser", tmp); - tmp = (char*)PQparameterStatus(pgsql, "session_authorization"); - add_assoc_string(return_value, "session_authorization", tmp); - tmp = (char*)PQparameterStatus(pgsql, "DateStyle"); - add_assoc_string(return_value, "DateStyle", tmp); - tmp = (char*)PQparameterStatus(pgsql, "IntervalStyle"); - add_assoc_string(return_value, "IntervalStyle", tmp ? tmp : ""); - tmp = (char*)PQparameterStatus(pgsql, "TimeZone"); - add_assoc_string(return_value, "TimeZone", tmp ? tmp : ""); - tmp = (char*)PQparameterStatus(pgsql, "integer_datetimes"); - add_assoc_string(return_value, "integer_datetimes", tmp ? tmp : ""); - tmp = (char*)PQparameterStatus(pgsql, "standard_conforming_strings"); - add_assoc_string(return_value, "standard_conforming_strings", tmp ? tmp : ""); - tmp = (char*)PQparameterStatus(pgsql, "application_name"); - add_assoc_string(return_value, "application_name", tmp ? tmp : ""); + +#define PHP_PQ_COPY_PARAM(_x) tmp = (char*)PQparameterStatus(pgsql, _x); \ + if(tmp) add_assoc_string(return_value, _x, tmp); \ + else add_assoc_null(return_value, _x); + + PHP_PQ_COPY_PARAM("server_encoding"); + PHP_PQ_COPY_PARAM("client_encoding"); + PHP_PQ_COPY_PARAM("is_superuser"); + PHP_PQ_COPY_PARAM("session_authorization"); + PHP_PQ_COPY_PARAM("DateStyle"); + PHP_PQ_COPY_PARAM("IntervalStyle"); + PHP_PQ_COPY_PARAM("TimeZone"); + PHP_PQ_COPY_PARAM("integer_datetimes"); + PHP_PQ_COPY_PARAM("standard_conforming_strings"); + PHP_PQ_COPY_PARAM("application_name"); } #endif #endif

« previous php.cvs (#100597) next »