v3-0003-Fix-bug-in-TOC-file-error-message-printing.patch
application/octet-stream
Filename: v3-0003-Fix-bug-in-TOC-file-error-message-printing.patch
Type: application/octet-stream
Part: 0
Message:
Re: Unbounded %s in sscanf
Patch
Format: format-patch
Series: patch v3-0003
Subject: Fix bug in TOC file error message printing
| File | + | − |
|---|---|---|
| src/bin/pg_dump/pg_backup_directory.c | 7 | 7 |
From b66de1c7c8832f1f78aa3b57e48cef89261bdf92 Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <daniel@yesql.se>
Date: Tue, 29 Jun 2021 09:46:09 +0200
Subject: [PATCH v3 3/3] Fix bug in TOC file error message printing
If the blob TOC file cannot be parsed, the error message was failing
to print the filename as the variable holding it was shadowed by the
destination buffer for parsing. Fix by renaming the outer scope var.
---
src/bin/pg_dump/pg_backup_directory.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
index 57243c5971..7c8b86827a 100644
--- a/src/bin/pg_dump/pg_backup_directory.c
+++ b/src/bin/pg_dump/pg_backup_directory.c
@@ -433,18 +433,18 @@ _LoadBlobs(ArchiveHandle *AH)
{
Oid oid;
lclContext *ctx = (lclContext *) AH->formatData;
- char fname[MAXPGPATH];
+ char tocfname[MAXPGPATH];
char line[MAXPGPATH];
StartRestoreBlobs(AH);
- setFilePath(AH, fname, "blobs.toc");
+ setFilePath(AH, tocfname, "blobs.toc");
- ctx->blobsTocFH = cfopen_read(fname, PG_BINARY_R);
+ ctx->blobsTocFH = cfopen_read(tocfname, PG_BINARY_R);
if (ctx->blobsTocFH == NULL)
fatal("could not open large object TOC file \"%s\" for input: %m",
- fname);
+ tocfname);
/* Read the blobs TOC file line-by-line, and process each blob */
while ((cfgets(ctx->blobsTocFH, line, MAXPGPATH)) != NULL)
@@ -455,7 +455,7 @@ _LoadBlobs(ArchiveHandle *AH)
/* Can't overflow because line and fname are the same length. */
if (sscanf(line, "%u %" CppAsString2(MAXPGPATH) "s\n", &oid, fname) != 2)
fatal("invalid line in large object TOC file \"%s\": \"%s\"",
- fname, line);
+ tocfname, line);
StartRestoreBlob(AH, oid, AH->public.ropt->dropSchema);
snprintf(path, MAXPGPATH, "%s/%s", ctx->directory, fname);
@@ -464,11 +464,11 @@ _LoadBlobs(ArchiveHandle *AH)
}
if (!cfeof(ctx->blobsTocFH))
fatal("error reading large object TOC file \"%s\"",
- fname);
+ tocfname);
if (cfclose(ctx->blobsTocFH) != 0)
fatal("could not close large object TOC file \"%s\": %m",
- fname);
+ tocfname);
ctx->blobsTocFH = NULL;
--
2.30.1 (Apple Git-130)