]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix sscanf limits in pg_basebackup and pg_dump
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Tue, 19 Oct 2021 10:59:50 +0000 (12:59 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Tue, 19 Oct 2021 10:59:50 +0000 (12:59 +0200)
commit121be6a665aaf64e0fe45b424cd26b53b384dc31
treec1cd1e32065db9c29d8a79072e55995f8be90359
parentb1b797ec71a1a8cc6bb500313f4373bcb5aac1ff
Fix sscanf limits in pg_basebackup and pg_dump

Make sure that the string parsing is limited by the size of the
destination buffer.

In pg_basebackup the available values sent from the server
is limited to two characters so there was no risk of overflow.

In pg_dump the buffer is bounded by MAXPGPATH, and thus the limit
must be inserted via preprocessor expansion and the buffer increased
by one to account for the terminator. There is no risk of overflow
here, since in this case, the buffer scanned is smaller than the
destination buffer.

Backpatch the pg_basebackup fix to 11 where it was introduced, and
the pg_dump fix all the way down to 9.6.

Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/B14D3D7B-F98C-4E20-9459-C122C67647FB@yesql.se
Backpatch-through: 11 and 9.6
src/bin/pg_basebackup/streamutil.c
src/bin/pg_dump/pg_backup_directory.c