Skip to content

Commit 19b32bd

Browse files
committed
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.)
1 parent a42c443 commit 19b32bd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

doc/src/sgml/ref/pg_basebackup.sgml

+8-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ PostgreSQL documentation
157157
the target directory. If the cluster contains additional
158158
tablespaces, the main data directory will be placed in the
159159
target directory, but all other tablespaces will be placed
160-
in the same absolute path as they have on the server.
160+
in the same absolute path as they have on the source server.
161+
(See <option>--tablespace-mapping</option> to change that.)
161162
</para>
162163
<para>
163164
This is the default format.
@@ -267,7 +268,12 @@ PostgreSQL documentation
267268
the main data directory are updated to point to the new location. So
268269
the new data directory is ready to be used for a new server instance
269270
with all tablespaces in the updated locations.
270-
</para>
271+
</para>
272+
273+
<para>
274+
Currently, this option only works with plain output format; it is
275+
ignored if tar format is selected.
276+
</para>
271277
</listitem>
272278
</varlistentry>
273279

src/backend/access/transam/xlog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11179,7 +11179,7 @@ read_tablespace_map(List **tablespaces)
1117911179
}
1118011180
else if ((ch == '\n' || ch == '\r') && prev_ch == '\\')
1118111181
str[i - 1] = ch;
11182-
else
11182+
else if (i < sizeof(str) - 1)
1118311183
str[i++] = ch;
1118411184
prev_ch = ch;
1118511185
}

0 commit comments

Comments
 (0)