Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Avoid non-constant format string argument to fprintf().
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 18 Aug 2020 10:13:09 +0000 (13:13 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 18 Aug 2020 10:13:09 +0000 (13:13 +0300)
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

src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_checksums/pg_checksums.c
src/bin/pg_rewind/pg_rewind.c

index 8158c8e419574c6660f9701fc048dc6e7655e14d..7a5d4562f9461a98ce5df3c5e74a6a29efc35654 100644 (file)
@@ -860,7 +860,7 @@ progress_report(int tablespacenum, const char *filename,
     * Stay on the same line if reporting to a terminal and we're not done
     * yet.
     */
-   fprintf(stderr, (!finished && isatty(fileno(stderr))) ? "\r" : "\n");
+   fputc((!finished && isatty(fileno(stderr))) ? '\r' : '\n', stderr);
 }
 
 static int32
index 0696db69bbd54ffbf8b6275928aaffd5767aaa20..ffdc23945c6dcb77ecc72bec8201764d92a9cf86 100644 (file)
@@ -166,7 +166,7 @@ progress_report(bool finished)
     * Stay on the same line if reporting to a terminal and we're not done
     * yet.
     */
-   fprintf(stderr, (!finished && isatty(fileno(stderr))) ? "\r" : "\n");
+   fputc((!finished && isatty(fileno(stderr))) ? '\r' : '\n', stderr);
 }
 
 static bool
index a9aecc7905286bc4a6e93f7105779c750043bc67..23fc749e445150119158777bcb1b2b357dd87b41 100644 (file)
@@ -572,7 +572,7 @@ progress_report(bool finished)
     * Stay on the same line if reporting to a terminal and we're not done
     * yet.
     */
-   fprintf(stderr, (!finished && isatty(fileno(stderr))) ? "\r" : "\n");
+   fputc((!finished && isatty(fileno(stderr))) ? '\r' : '\n', stderr);
 }
 
 /*