postgres.git / summary / log / commit / refs

commit    b77e5d73bcfc0810e7a4eab29cfbc2859adb8db9
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Wed Mar 17 20:10:37 2021 +0000
First released in: 14.0, 9.6.22, 10.17, 11.12, 12.7, 13.3

    Prevent buffer overrun in read_tablespace_map().
    
    Robert Foggia of Trustwave reported that read_tablespace_map()
    fails to prevent an overrun of its on-stack input buffer.
    Since the tablespace map file is presumed trustworthy, this does
    not seem like an interesting security vulnerability, but still
    we should fix it just in the name of robustness.
    
    While here, document that pg_basebackup's --tablespace-mapping option
    doesn't work with tar-format output, because it doesn't.  To make it
    work, we'd have to modify the tablespace_map file within the tarball
    sent by the server, which might be possible but I'm not volunteering.
    (Less-painful solutions would require changing the basebackup protocol
    so that the source server could adjust the map.  That's not very
    appetizing either.)


doc/src/sgml/ref/pg_basebackup.sgml | 8 +++++++- src/backend/access/transam/xlog.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index 5754ad5aa6b..03f31b2879d 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -161,6 +161,7 @@ PostgreSQL documentation tablespaces, the main data directory will be placed in the target directory, but all other tablespaces will be placed in the same absolute path as they have on the source server. + (See <option>--tablespace-mapping</option> to change that.) </para> <para> This is the default format. @@ -241,7 +242,12 @@ PostgreSQL documentation the main data directory are updated to point to the new location. So the new data directory is ready to be used for a new server instance with all tablespaces in the updated locations. - </para> + </para> + + <para> + Currently, this option only works with plain output format; it is + ignored if tar format is selected. + </para> </listitem> </varlistentry> diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 7daa7c43ad5..91e99d059f2 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -11718,7 +11718,7 @@ read_tablespace_map(List **tablespaces) } else if ((ch == '\n' || ch == '\r') && prev_ch == '\\') str[i - 1] = ch; - else + else if (i < sizeof(str) - 1) str[i++] = ch; prev_ch = ch; } [parent: 69739ec317ae]