Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7825f9b

Browse files
committed
Fix for tprintf overruns from Göran Thyni.
1 parent ccbe540 commit 7825f9b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/backend/utils/misc/trace.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ tprintf(int flag, const char *fmt,...)
108108
#ifdef ELOG_TIMESTAMPS
109109
strcpy(line, tprintf_timestamp());
110110
#endif
111-
vsprintf(line + TIMESTAMP_SIZE, fmt, ap);
111+
vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN,
112+
fmt, ap);
112113
va_end(ap);
113114

114115
#ifdef USE_SYSLOG
@@ -138,7 +139,8 @@ tprintf1(const char *fmt, ... )
138139
#ifdef ELOG_TIMESTAMPS
139140
strcpy(line, tprintf_timestamp());
140141
#endif
141-
vsprintf(line+TIMESTAMP_SIZE, fmt, ap);
142+
vsnprintf(line+TIMESTAMP_SIZE, ELOG_MAXLEN,
143+
fmt, ap);
142144
va_end(ap);
143145

144146
#ifdef USE_SYSLOG
@@ -166,7 +168,8 @@ eprintf(const char *fmt,...)
166168
#ifdef ELOG_TIMESTAMPS
167169
strcpy(line, tprintf_timestamp());
168170
#endif
169-
vsprintf(line + TIMESTAMP_SIZE, fmt, ap);
171+
vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN,
172+
fmt, ap);
170173
va_end(ap);
171174

172175
#ifdef USE_SYSLOG
@@ -344,7 +347,8 @@ read_pg_options(SIGNAL_ARGS)
344347
return;
345348
}
346349

347-
sprintf(buffer, "%s/%s", DataDir, "pg_options");
350+
snprintf(buffer, BUF_SIZE - 1,
351+
"%s/%s", DataDir, "pg_options");
348352
if ((fd = open(buffer, O_RDONLY)) < 0)
349353
return;
350354

0 commit comments

Comments
 (0)