pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix stale attribute pointer in COPY FROM error context. 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix stale attribute pointer in COPY FROM error context. @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 4+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix stale attribute pointer in COPY FROM error context. Previously, cur_attname and cur_attval were left set when ON_ERROR was 'ignore' or 'set_null'. As a result, if an error was raised while processing the next row, the COPY error context callback could dereference a pointer that no longer belonged to it. cur_attval isn't a copy of the field value; it points into attribute_buf, which the next row resets and, for a longer line, repallocs. The callback measures the value with strlen() before applying the display limit, so the limit bounds what we print but not what we read. So depending on what has reused the allocation, the CONTEXT line reports a value from the previous row or bytes belonging to something else entirely. file_fdw reaches the same code through its soft-error retry loop, so on v18 and later, a SELECT or ANALYZE on such a foreign table hits this too. Fix this by making sure to clear both fields before processing the next column data. This also corrects the context reported for a REJECT_LIMIT overrun, which is a statement-level error but was picking up the column and value left behind by the last skipped row. Backpatch to v17, where ON_ERROR was introduced. Reported-by: 안지용 <jfdg1y76@gmail.com> Backpatch-through: 17 Security: CVE-2026-116310 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/4d93c03843fb29ae5878716eceb8c6520d9f4376 Author: Masahiko Sawada <msawada@postgresql.org> Modified Files -------------- contrib/file_fdw/expected/file_fdw.out | 2 +- src/backend/commands/copyfromparse.c | 10 ++++++++-- src/test/regress/expected/copy2.out | 13 ++++++++++++- src/test/regress/sql/copy2.sql | 17 +++++++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix stale attribute pointer in COPY FROM error context. @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 4+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix stale attribute pointer in COPY FROM error context. Previously, cur_attname and cur_attval were left set when ON_ERROR was 'ignore' or 'set_null'. As a result, if an error was raised while processing the next row, the COPY error context callback could dereference a pointer that no longer belonged to it. cur_attval isn't a copy of the field value; it points into attribute_buf, which the next row resets and, for a longer line, repallocs. The callback measures the value with strlen() before applying the display limit, so the limit bounds what we print but not what we read. So depending on what has reused the allocation, the CONTEXT line reports a value from the previous row or bytes belonging to something else entirely. file_fdw reaches the same code through its soft-error retry loop, so on v18 and later, a SELECT or ANALYZE on such a foreign table hits this too. Fix this by making sure to clear both fields before processing the next column data. This also corrects the context reported for a REJECT_LIMIT overrun, which is a statement-level error but was picking up the column and value left behind by the last skipped row. Backpatch to v17, where ON_ERROR was introduced. Reported-by: 안지용 <jfdg1y76@gmail.com> Backpatch-through: 17 Security: CVE-2026-116310 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8b3babb6e1627928fb0111f48e0c8a9435c7633e Author: Masahiko Sawada <msawada@postgresql.org> Modified Files -------------- contrib/file_fdw/expected/file_fdw.out | 2 +- src/backend/commands/copyfromparse.c | 10 ++++++++-- src/test/regress/expected/copy2.out | 13 ++++++++++++- src/test/regress/sql/copy2.sql | 17 +++++++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix stale attribute pointer in COPY FROM error context. @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 4+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix stale attribute pointer in COPY FROM error context. Previously, cur_attname and cur_attval were left set when ON_ERROR was 'ignore' or 'set_null'. As a result, if an error was raised while processing the next row, the COPY error context callback could dereference a pointer that no longer belonged to it. cur_attval isn't a copy of the field value; it points into attribute_buf, which the next row resets and, for a longer line, repallocs. The callback measures the value with strlen() before applying the display limit, so the limit bounds what we print but not what we read. So depending on what has reused the allocation, the CONTEXT line reports a value from the previous row or bytes belonging to something else entirely. file_fdw reaches the same code through its soft-error retry loop, so on v18 and later, a SELECT or ANALYZE on such a foreign table hits this too. Fix this by making sure to clear both fields before processing the next column data. This also corrects the context reported for a REJECT_LIMIT overrun, which is a statement-level error but was picking up the column and value left behind by the last skipped row. Backpatch to v17, where ON_ERROR was introduced. Reported-by: 안지용 <jfdg1y76@gmail.com> Backpatch-through: 17 Security: CVE-2026-116310 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8d9f203b81483e30ff71daaa57ba0038e0568b77 Author: Masahiko Sawada <msawada@postgresql.org> Modified Files -------------- contrib/file_fdw/expected/file_fdw.out | 2 +- src/backend/commands/copyfromparse.c | 4 ++++ src/test/regress/expected/copy2.out | 10 +++++++++- src/test/regress/sql/copy2.sql | 12 ++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix stale attribute pointer in COPY FROM error context. @ 2026-11-09 14:22 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 4+ messages in thread From: Noah Misch @ 2026-11-09 14:22 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix stale attribute pointer in COPY FROM error context. Previously, cur_attname and cur_attval were left set when ON_ERROR was 'ignore' or 'set_null'. As a result, if an error was raised while processing the next row, the COPY error context callback could dereference a pointer that no longer belonged to it. cur_attval isn't a copy of the field value; it points into attribute_buf, which the next row resets and, for a longer line, repallocs. The callback measures the value with strlen() before applying the display limit, so the limit bounds what we print but not what we read. So depending on what has reused the allocation, the CONTEXT line reports a value from the previous row or bytes belonging to something else entirely. file_fdw reaches the same code through its soft-error retry loop, so on v18 and later, a SELECT or ANALYZE on such a foreign table hits this too. Fix this by making sure to clear both fields before processing the next column data. This also corrects the context reported for a REJECT_LIMIT overrun, which is a statement-level error but was picking up the column and value left behind by the last skipped row. Backpatch to v17, where ON_ERROR was introduced. Reported-by: 안지용 <jfdg1y76@gmail.com> Backpatch-through: 17 Security: CVE-2026-116310 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3094cdb7d97384eb18587908f10583462a997a44 Author: Masahiko Sawada <msawada@postgresql.org> Modified Files -------------- src/backend/commands/copyfromparse.c | 4 ++++ src/test/regress/expected/copy2.out | 8 ++++++++ src/test/regress/sql/copy2.sql | 12 ++++++++++++ 3 files changed, 24 insertions(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-11-09 14:22 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-09 14:21 pgsql: Fix stale attribute pointer in COPY FROM error context. Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Fix stale attribute pointer in COPY FROM error context. Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Fix stale attribute pointer in COPY FROM error context. Noah Misch <noah@leadboat.com> 2026-11-09 14:22 pgsql: Fix stale attribute pointer in COPY FROM error context. Noah Misch <noah@leadboat.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox