summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2021-02-05 12:53:25 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2021-02-08 18:57:08 +0100
commit03713ace23e7c8fa6b7d31684de8740a77e42895 (patch)
tree7c56ad954ba479e25af830e52e25a989b3f4197c
parentca7547c9e2f9120768d8290001ec6e1509b3597f (diff)
downloadphp-git-03713ace23e7c8fa6b7d31684de8740a77e42895.tar.gz
Fix locale dependent parsing of PostgreSQL version number
Version numbers are not supposed to be localized, so we must not apply locale dependent parsing with `atof()`. Using `php_version_compare()` might even be better. Closes GH-6668.
-rw-r--r--ext/pgsql/pgsql.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 9f51256ac5..22e0825c54 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -1424,9 +1424,10 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
pgsql = (PGconn *) le->ptr;
#if HAVE_PQPROTOCOLVERSION && HAVE_PQPARAMETERSTATUS
- if (PQprotocolVersion(pgsql) >= 3 && atof(PQparameterStatus(pgsql, "server_version")) >= 7.2) {
+ /* consider to use php_version_compare() here */
+ if (PQprotocolVersion(pgsql) >= 3 && zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 7.2) {
#else
- if (atof(PG_VERSION) >= 7.2) {
+ if (zend_strtod(PG_VERSION, NULL) >= 7.2) {
#endif
pg_result = PQexec(pgsql, "RESET ALL;");
PQclear(pg_result);
@@ -5326,9 +5327,10 @@ PHP_FUNCTION(pg_get_notify)
add_index_string(return_value, 0, pgsql_notify->relname);
add_index_long(return_value, 1, pgsql_notify->be_pid);
#if HAVE_PQPROTOCOLVERSION && HAVE_PQPARAMETERSTATUS
- if (PQprotocolVersion(pgsql) >= 3 && atof(PQparameterStatus(pgsql, "server_version")) >= 9.0) {
+ /* consider to use php_version_compare() here */
+ if (PQprotocolVersion(pgsql) >= 3 && zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 9.0) {
#else
- if (atof(PG_VERSION) >= 9.0) {
+ if (zend_strtod(PG_VERSION) >= 9.0, NULL) {
#endif
#if HAVE_PQPARAMETERSTATUS
add_index_string(return_value, 2, pgsql_notify->extra);
@@ -5339,9 +5341,10 @@ PHP_FUNCTION(pg_get_notify)
add_assoc_string(return_value, "message", pgsql_notify->relname);
add_assoc_long(return_value, "pid", pgsql_notify->be_pid);
#if HAVE_PQPROTOCOLVERSION && HAVE_PQPARAMETERSTATUS
- if (PQprotocolVersion(pgsql) >= 3 && atof(PQparameterStatus(pgsql, "server_version")) >= 9.0) {
+ /* consider to use php_version_compare() here */
+ if (PQprotocolVersion(pgsql) >= 3 && zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 9.0) {
#else
- if (atof(PG_VERSION) >= 9.0) {
+ if (zend_strtod(PG_VERSION, NULL) >= 9.0) {
#endif
#if HAVE_PQPARAMETERSTATUS
add_assoc_string(return_value, "payload", pgsql_notify->extra);