summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-10-13 15:36:09 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-10-13 15:37:13 +0200
commit7b0f5f424d7a96f2d7f021660a5280a6565a049d (patch)
treed2141b6265689737cf378f08d7793ff57621f678
parent8e531b5b00247246ddc95f55e8b62d0f7cca0093 (diff)
downloadphp-git-7b0f5f424d7a96f2d7f021660a5280a6565a049d.tar.gz
Don't accept null in pg_unescape_bytea()
This is an error that slipped in via 8d37c37bcdbf6fa99cd275413342457eeb2c664e. pg_unescape_bytea() did not accept null in PHP 7.4, and it is not meaningful for it to accept null now -- it will always fail, and now with a misleading OOM message.
-rw-r--r--ext/pgsql/pgsql.c3
-rw-r--r--ext/pgsql/pgsql.stub.php2
-rw-r--r--ext/pgsql/pgsql_arginfo.h6
3 files changed, 5 insertions, 6 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 88cf0c431e..aac2afd493 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -3359,8 +3359,7 @@ PHP_FUNCTION(pg_unescape_bytea)
char *from, *tmp;
size_t to_len;
size_t from_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!",
- &from, &from_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &from, &from_len) == FAILURE) {
RETURN_THROWS();
}
diff --git a/ext/pgsql/pgsql.stub.php b/ext/pgsql/pgsql.stub.php
index 66044b95a5..759313d8ba 100644
--- a/ext/pgsql/pgsql.stub.php
+++ b/ext/pgsql/pgsql.stub.php
@@ -425,7 +425,7 @@ function pg_escape_string($connection, string $string = UNKNOWN): string {}
/** @param resource|string $connection */
function pg_escape_bytea($connection, string $string = UNKNOWN): string {}
-function pg_unescape_bytea(?string $string = null): string {}
+function pg_unescape_bytea(string $string): string {}
/** @param resource|string $connection */
function pg_escape_literal($connection, string $string = UNKNOWN): string|false {}
diff --git a/ext/pgsql/pgsql_arginfo.h b/ext/pgsql/pgsql_arginfo.h
index be9edb2c57..6db1b8a1c3 100644
--- a/ext/pgsql/pgsql_arginfo.h
+++ b/ext/pgsql/pgsql_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 3479aee134cb8d952c846d120f51a8cf75e55e86 */
+ * Stub hash: deb01afb2b4e645c00684fae61a6042ebfbaaaa1 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_connect, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, connection_string, IS_STRING, 0)
@@ -327,8 +327,8 @@ ZEND_END_ARG_INFO()
#define arginfo_pg_escape_bytea arginfo_pg_escape_string
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pg_unescape_bytea, 0, 0, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, string, IS_STRING, 1, "null")
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pg_unescape_bytea, 0, 1, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pg_escape_literal, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)