Skip to content

Commit 709c2f7

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: exp/pgsql: insert/update query string build possible UB fix.
2 parents 8eb63a2 + 5785ff7 commit 709c2f7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ PHP NEWS
3434
. Fixed bug GH-20882 (buildFromIterator breaks with missing base directory).
3535
(ndossche)
3636

37+
- PGSQL:
38+
. Fixed INSERT/UPDATE queries building with PQescapeIdentifier() and possible
39+
UB. (David Carlier)
40+
3741
- Readline:
3842
. Fixed bug GH-18139 (Memory leak when overriding some settings
3943
via readline_info()). (ndossche)

ext/pgsql/pgsql.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5681,7 +5681,7 @@ PHP_PGSQL_API zend_result php_pgsql_insert(PGconn *pg_link, const zend_string *t
56815681
goto cleanup;
56825682
}
56835683
if (opt & PGSQL_DML_ESCAPE) {
5684-
tmp = PQescapeIdentifier(pg_link, ZSTR_VAL(fld), ZSTR_LEN(fld) + 1);
5684+
tmp = PQescapeIdentifier(pg_link, ZSTR_VAL(fld), ZSTR_LEN(fld));
56855685
if (tmp == NULL) {
56865686
php_error_docref(NULL, E_NOTICE, "Failed to escape field '%s'", ZSTR_VAL(fld));
56875687
goto cleanup;
@@ -5866,7 +5866,7 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr,
58665866
return -1;
58675867
}
58685868
if (opt & PGSQL_DML_ESCAPE) {
5869-
char *tmp = PQescapeIdentifier(pg_link, ZSTR_VAL(fld), ZSTR_LEN(fld) + 1);
5869+
char *tmp = PQescapeIdentifier(pg_link, ZSTR_VAL(fld), ZSTR_LEN(fld));
58705870
if (tmp == NULL) {
58715871
php_error_docref(NULL, E_NOTICE, "Failed to escape field '%s'", ZSTR_VAL(fld));
58725872
return -1;

0 commit comments

Comments
 (0)