summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-02-09 19:45:38 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2019-02-09 19:45:38 -0500
commited46d0d322b54b618557b88948c72bc2711d7c1b (patch)
tree20fbe066ac1de802d5d9d3bb96e0b929b6cf81d4 /src
parent37f3a7751efb2c2c3128dbc9f2571a99fe5f6396 (diff)
Repair unsafe/unportable snprintf usage in pg_restore.
warn_or_exit_horribly() was blithely passing a potentially-NULL string pointer to a %s format specifier. That works (at least to the extent of not crashing) on some platforms, but not all, and since we switched to our own snprintf.c it doesn't work for us anywhere. Of the three string fields being handled this way here, I think that only "owner" is supposed to be nullable ... but considering that this is error-reporting code, it has very little business assuming anything, so put in defenses for all three. Per a crash observed on buildfarm member crake and then reproduced here. Because of the portability aspect, back-patch to all supported versions.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 04a2ad38c8c..eb972d16522 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -1676,8 +1676,11 @@ warn_or_exit_horribly(ArchiveHandle *AH,
{
write_msg(modulename, "Error from TOC entry %d; %u %u %s %s %s\n",
AH->currentTE->dumpId,
- AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid,
- AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
+ AH->currentTE->catalogId.tableoid,
+ AH->currentTE->catalogId.oid,
+ AH->currentTE->desc ? AH->currentTE->desc : "(no desc)",
+ AH->currentTE->tag ? AH->currentTE->tag : "(no tag)",
+ AH->currentTE->owner ? AH->currentTE->owner : "(no owner)");
}
AH->lastErrorStage = AH->stage;
AH->lastErrorTE = AH->currentTE;