Skip to content

Commit aecefff

Browse files
committed
Avoid non-constant format string argument to fprintf().
As Tom Lane pointed out, it could defeat the compiler's printf() format string verification. Backpatch to v12, like that patch that introduced it. Discussion: https://www.postgresql.org/message-id/1069283.1597672779%40sss.pgh.pa.us
1 parent 4f47c8e commit aecefff

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ progress_report(int tablespacenum, const char *filename,
801801
* Stay on the same line if reporting to a terminal and we're not done
802802
* yet.
803803
*/
804-
fprintf(stderr, (!finished && isatty(fileno(stderr))) ? "\r" : "\n");
804+
fputc((!finished && isatty(fileno(stderr))) ? '\r' : '\n', stderr);
805805
}
806806

807807
static int32

src/bin/pg_checksums/pg_checksums.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ progress_report(bool finished)
165165
* Stay on the same line if reporting to a terminal and we're not done
166166
* yet.
167167
*/
168-
fprintf(stderr, (!finished && isatty(fileno(stderr))) ? "\r" : "\n");
168+
fputc((!finished && isatty(fileno(stderr))) ? '\r' : '\n', stderr);
169169
}
170170

171171
static bool

src/bin/pg_rewind/pg_rewind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ progress_report(bool finished)
505505
* Stay on the same line if reporting to a terminal and we're not done
506506
* yet.
507507
*/
508-
fprintf(stderr, (!finished && isatty(fileno(stderr))) ? "\r" : "\n");
508+
fputc((!finished && isatty(fileno(stderr))) ? '\r' : '\n', stderr);
509509
}
510510

511511
/*

0 commit comments

Comments
 (0)