pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Read until EOF vice stat-reported size in read_binary_file
Date: Sat, 04 Jul 2020 10:30:14 +0000
Message-ID: <E1jrfR0-0000gV-1Y@gemulon.postgresql.org> (raw)

Read until EOF vice stat-reported size in read_binary_file

read_binary_file(), used by SQL functions pg_read_file() and friends,
uses stat to determine file length to read, when not passed an explicit
length as an argument. This is problematic, for example, if the file
being read is a virtual file with a stat-reported length of zero.
Arrange to read until EOF, or StringInfo data string lenth limit, is
reached instead.

Original complaint and patch by me, with significant review, corrections,
advice, and code optimizations by Tom Lane. Backpatched to v11. Prior to
that only paths relative to the data and log dirs were allowed for files,
so no "zero length" files were reachable anyway.

Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/flat/969b8d82-5bb2-5fa8-4eb1-f0e685c5d736%40joeconway.com
Backpatch-through: 11

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0025c3a2c295459002711e0b37e48e3b067a83ba

Modified Files
--------------
contrib/adminpack/expected/adminpack.out |  4 +-
src/backend/utils/adt/genfile.c          | 91 ++++++++++++++++++++++----------
2 files changed, 66 insertions(+), 29 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1jrfR0-0000gV-1Y@gemulon.postgresql.org>
Permalink:  ../E1jrfR0-0000gV-1Y@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jrfR0-0000gV-1Y@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: mail@joeconway.com
  Subject: Re: pgsql: Read until EOF vice stat-reported size in read_binary_file
  In-Reply-To: <E1jrfR0-0000gV-1Y@gemulon.postgresql.org>
  References: <E1jrfR0-0000gV-1Y@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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