From 7825f9b890a50a6ce47d8926fe4d18523bc7ae6b Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 27 Oct 1998 03:26:48 +0000 Subject: [PATCH] =?utf8?q?Fix=20for=20tprintf=20overruns=20from=20G=C3=B6r?= =?utf8?q?an=20Thyni.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/backend/utils/misc/trace.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c index 0f58a122dd..83ef5bb449 100644 --- a/src/backend/utils/misc/trace.c +++ b/src/backend/utils/misc/trace.c @@ -108,7 +108,8 @@ tprintf(int flag, const char *fmt,...) #ifdef ELOG_TIMESTAMPS strcpy(line, tprintf_timestamp()); #endif - vsprintf(line + TIMESTAMP_SIZE, fmt, ap); + vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, + fmt, ap); va_end(ap); #ifdef USE_SYSLOG @@ -138,7 +139,8 @@ tprintf1(const char *fmt, ... ) #ifdef ELOG_TIMESTAMPS strcpy(line, tprintf_timestamp()); #endif - vsprintf(line+TIMESTAMP_SIZE, fmt, ap); + vsnprintf(line+TIMESTAMP_SIZE, ELOG_MAXLEN, + fmt, ap); va_end(ap); #ifdef USE_SYSLOG @@ -166,7 +168,8 @@ eprintf(const char *fmt,...) #ifdef ELOG_TIMESTAMPS strcpy(line, tprintf_timestamp()); #endif - vsprintf(line + TIMESTAMP_SIZE, fmt, ap); + vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, + fmt, ap); va_end(ap); #ifdef USE_SYSLOG @@ -344,7 +347,8 @@ read_pg_options(SIGNAL_ARGS) return; } - sprintf(buffer, "%s/%s", DataDir, "pg_options"); + snprintf(buffer, BUF_SIZE - 1, + "%s/%s", DataDir, "pg_options"); if ((fd = open(buffer, O_RDONLY)) < 0) return; -- 2.40.0